Part 1: ARM Templates – A Walkthrough

Hey there folks, it’s been a while since I’ve posted anything as I’ve been spending the last couple of months finishing off a few projects at work. In the gaps, I’ve been putting a little time aside to try and get to grips with Azure Resource Manager templates, how they’re put together and how I go about making use of them.

I’ve had a play about with ARM before and knew the basic concepts but it mainly consisted around deploying single IaaS VMs with various OS versions, Storage Account types and roles, I wanted something MORE!

With that in mind, I went to the obvious place to look for something with a little more meat on the bone…nothing too crazy first time out though: https://github.com/Azure/azure-quickstart-templates/

The above GitHub repo is a great place to start as it has a massive collection of templates ranging from introductory to really quite advanced, and although advanced is my goal, let’s start with something more manageable.

I ended up settling on the following template as a base:

https://github.com/Azure/azure-quickstart-templates/tree/master/iis-2vm-sql-1vm

The reason I chose this template is because:

  • It’s REALLY well documented, kudos to its creator Ali Baloch at Microsoft
  • It has some basic choices around it’s deployment without getting too complex
  • I deploys most of the important resources that I wanted to get some hands on experience with

I suggest having a look at the above link when you get a minute as I think it’s a great example of putting a template together.

Now, as I said above, I used this template as my base for learning purposes. From here on out we’ll we discussing the template I created from it, as jumping back and forward between them is likely to get confusing quickly.

If you’re completely new to ARM templates, I go over them at a fairly high level in a previous GUIDE

NOTE: If you already have an Azure subscription and a GitHub account, feel free to skip this guide and move immediately on to part 2 where the fun stuff begins.

 

What Do I Need to get Started?

Azure Subscription

As part of this guide we’ll actually be deploying our template into Azure, as such, you’ll need access to an Azure subscription. No worries on that front though as Microsoft has you covered, you can sign up for a Visual Studio Dev Essentials subscription which will give you £20 of free Azure credit per month. This credit is reset every month, so unspent credit doesn’t roll into the next month…someone was going to ask 🙂

So let’s get an account set up then:

NOTE: This part assumes you already have a Microsoft account (outlook.com, hotmail.co.uk etc.):

clip_image001

  • You’ll be prompted for to confirm your name, email address and region. You can also choose to opt in for some MS marketing material if that tickles your fancy.
  • Click “Continue”

clip_image002

  • Feel free to read the welcome banner and click “Confirm” when you’re done

clip_image003

  • Locate the “Azure” tile and click “Activate”

clip_image004

  • Enter your registration details and click “Next”

clip_image005

  • For your first verification step, you’ll need to enter a mobile number and choose “Text me” or “Call me”

clip_image006

  • Once you receive your code, enter it into the box and click “Verify Code”

clip_image007

NOTE:  You’ll now be asked to enter credit card details to confirm your identity. You will NOT be charged anything for doing this and there is no roll on once your free Azure credit expires. After the 30 days your account will change to a “Developer Program Benefit” subscription where you will have access to £20 of Azure credit per month, if you exhaust those credits in the month, any services you are running will stop, you will not be charged at this point either.

OK, so now that we’ve got that out of the way, let’s leave the portal behind for the time being, we’ll come back to it later.

 

GitHub Account

This part isn’t strictly required but using GitHub as a repository for your ARM templates is a good habit to get into, plus I want to go through README file configuration and how it gets parsed by GitHub, but we’ll get to that later.

NOTE:  We’ll be creating a public repository as it’s free, which means anything you place in this repo is publicly viewable, that should be an issue though as we’ll not be putting anything sensitive in our templates.

First let’s create an account:

clip_image008

  • Choose a “Username”, enter a valid “Email Address” and “Password” and click “Create an account”

clip_image009

  • Now choose your plan, we’re going with the free one here, click “Continue”

clip_image010

  • Either choose your preferences or click “Skip this step”
  • Now click “Start a project”

clip_image011

  • You’ll be prompted to verify your email address, follow the process to completion
  • Once you’re up and running, click “Start a project” again and you’ll be prompted to create your first repository (repo)
  • Enter the following information for your repo:
    • Repository Name
    • Description
    • Choose a “Public” repo
    • Tick “Initialize this repository with a README”
  • Now click “Create Repository”

clip_image012

OK, so now we have a GitHub account with a repository ready to go, and an Azure subscription waiting to deploy into.

One caveat before we continue. This guide will not focus on the best way to make use of GitHub, there are MANY fantastic guides out there already that go over that better than I ever could. For the most part, we’ll be using the portal for anything we need as it’s where I want to show you the changes as they’re applied, and it’s easy and requires no further configuration.

 

Choose an Integrated Scripting Environment (ISE)

There are many ISEs out there that will fit our particular use case, for this guide I’ll be using Visual Studio Code as it’s become my preferred tool over the last year or so. Don’t feel obliged to use it just because I do though :), pick whatever tool fits the bill and you’re most comfortable with.

Being that we just set up our Visual Studio Dev Essentials account, log in and click the tile “Visual Studio Code” to download and install the tool.

clip_image013

  • Choose the correct architecture for your OS (x86 or 64 Bit), run the installer and launch the program.

One of the benefits of this ISE is the ability to add “Extensions” to increase or augment its functionality. With that in mind we’re going to install the “Azure Resource Manager Tools” extension. This will give us really useful features like “IntelliSense” for the ARM Templates that we’re going to be working with.

NOTE: ARM templates are in JavaScript Object Notation (JSON) format. You can find out a little more about the JSON format HERE

clip_image014

To install the ARM Tools extension:

  • Click the “Extensions” button on the left navigation bar
  • Type “Azure Resource Manager Tools” into the search bar
  • Click “Install” (I’ve already got it install, hence the missing button)

clip_image015

OK, so I think that’s everything we’ll need going forward. See you in Part 2 where we start diving into the process.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.