Skip main navigation

New offer! Get 30% off your first 2 months of Unlimited Monthly. Start your subscription for just £29.99 £19.99. New subscribers only. T&Cs apply

Find out more

Azure Resource Manager Templates

This step shows users where to find and how to utilise pre-existing templates in the ARM marketplace.
17.1
This module will take a look at, in depth, the two deployment models that are available in Azure. But mainly we’re going to focus on the newer Azure Resource Manager, or ARM, deployment model. So what is Azure Resource Manager? Azure Resource Manager is a deployment methodology that allows you to define what it is you want for infrastructure. So you may have heard the term infrastructure as code, or declarative infrastructure. You’re not worrying about the workflow or the sequencing. If you’re a traditional IT pro or you’ve ever installed applications or set something up, if you’re building a database you’ve got to instal the operating system, instal the database, instal the database server then the database, instal your app, and then configure everything.
64.9
So there’s a workflow that you’ve got to go through. And if you’re going to script or automate that, if something fails you’ve got to build the logic to fail back and fix it and move on. And so in the past, deployment scripts, particularly automated deployments, could get very, very complex and very complicated. What Azure Resource Manager does is allows you to define your entire deployment in a file. And that file is called an ARM or Azure Resource Manager template. We’ll look at those in a little bit in depth.
96.8
But we can now define them as a file and then apply that file to an Azure subscription, effectively allowing Azure to take care of all the details of how that deployment is supposed to work. Now, there’s some additional benefits of this model. If, for example, your deployment is broken. You don’t need to figure out why or how, you can simply redeploy it if you’re doing test and dev. You can define the template and deploy it three times. Once for test, once for dev, and once for production. You can use these templates to create what are called resource groups, right? So as I take a template I could deploy it in a group.
141.6
And then the group becomes a unit for things like billing. So I can see how much I’m being charged per group. And then, additionally, you can do all this with PowerShell. So in addition to being able to define the templates, you can apply the templates with PowerShell, you can download templates with PowerShell, and you can also automate all the steps with PowerShell. Now, I had mentioned to you a second ago this notion of what’s called a resource group. A resource group is a unit within Azure within the new portal that contains objects. So when you deploy things with ARM templates, one of the requirements is it must be deployed into a group.
181.8
The group is something you can administer and manage as a unit. I can, for example, give an administrator control over a group and they can administer all the objects within that resource group. I can deploy the group as a template. I can check billing for the group. And perhaps the most convenient, I can delete the entire group and everything in that group in one click. Well, maybe three clicks. But one action, one operation.
210.3
How does that compare to the classic portal and the older methods? Let’s kind of take a quick look. Are there PowerShell modules for both? Yes there are. Can I use declarative templates to create resources, or do I have to rely on workflow? Only the new portal allows you to do that. Can I provide role-based administration? In other words, if I have two applications in the portal, can I give Bob control over one and Sally control over another? With resource groups, you can. The old portal, you cannot. You can administer the subscription or not. Can I create compute network storage? Yes, you can do that in both. Can I create multiple things at the same time?
251.2
Only in the new portal and only with ARM. Can I define dependencies? Only in the new portal. And then, can I create policies to control what can and cannot be done? Only in the new portal. So as you can see, the classic portal and Azure service manager, while it’s still available, is not the way you want to operate. You want to work in the new portal using the Azure Resource Manager method. Now, how do you choose this? Well, it’s actually very simple. Any time you’re in the new portal and you choose to create something. For example, I’m going to go New and I’m just going to create a Windows virtual machine.
290.8
Here’s a Windows Server 2012 R2 virtual machine. The very first thing it’s going to ask me is, what’s the deployment model that I want to use? And down here on the bottom, I can choose either classic, which is the service manager, or the new Resource Manager deployment model. Unless you’ve got a very specific reason, you always want to choose the Resource Manager deployment model. So it’s that simple. That’s how you choose the method that you’re going to use. When you choose that method, behind the scenes it’s going to leverage resource groups, ARM templates, and these newer technologies to deploy your objects within Azure. Now we keep bringing up the notion of an ARM template. So what is that?
335
Well, an ARM template is a text file. So many people are familiar with the notion of an XML file. Well, an ARM template is a JSON file. JSON stands for JavaScript Object Notation. And it’s a very simple file that uses a predictable– the first time you see it, admittedly, it you can look a little confusing. But it’s a very predictable, very structured syntax that’s used across many different types of services across the computing world. It’s not just templates for Azure. You can find this in many different places on many different platforms. Let’s look at an actual file and kind of see what it looks like. So this is an ARM template that’s loaded in Visual Studio.
381.3
This is the Visual Studio Community Edition, or the free edition of Visual Studio. And if we kind of start at the top, you can see it’s a fairly simple syntax, where I’ve got some parameters and then I’ve got a parameter called virtualMachines TravelAppServer adminPassword, which is going to be a secure string. It’s a password string. And then I’ve got a server name, which is also a string. And so you can see it’s a very simple, structured text file format. Now, no one’s expecting you to understand or know or be able to write in this format. Certainly, writing ARM templates from scratch is a bit of a skill that takes some time to learn.
425.1
There are, however, tools that make it quite easy. For example, this Visual Studio Community Edition has wizards and tools that allow you to build ARM templates. So I can come in here as I get more advanced and more skilled in Azure, and I want to define an application or an infrastructure or any number of objects within Azure, I can come into something like Visual Studio and create that object or create that definition and then use it as the basis for deployment. ARM templates are also used on public areas. I say public areas, but on resources and sites like GitHub as a method to help administrators build and deploy on Azure.
471.5
So for example, because this is the preferred way of doing things, one of the things that Microsoft does is they make available on GitHub a community-driven set of templates which are called the Azure quickstart templates. And so you can come out here on GitHub, to github.com/azure /azurequickstarttemplates, or fire up your favourite search engine, you’ll land here in the first or second hit. And these are a series of community– they’re not Microsoft-supported– they’re community-supported ARM templates that deploy all sorts of combinations of services on Azure. For example, if I scroll down, here’s a simple Windows virtual machine. I click on it, the Azure deployed JSON file is the actual deployment definition, and I can see here’s the template.
523.2
And again, as I become more skilled and used to working with ARM templates, I can edit this, I can make my own copy of it, I can modify it, I can use this as the basis for my own deployment. I’m not that skilled with this, however. I just want to get a virtual machine on Azure and I want to use this template for whatever reason. They give you a button which says, deploy to Azure. You click on it and now Azure’s just going to prompt you for a couple of bits of information– those parameters– and it’ll now proceed to use that template to deploy a Windows virtual machine up on Azure.
558.4
And you can see this one asks for three things, a username and a password. And based on that, you’ll get a copy of Windows 2012 R2 data centre. Now you might think, well, OK, that’s nice. But can’t I just click New and go to a virtual machine? And won’t that achieve the same thing? And the answer is, in this particular example, you’re absolutely right. However, what if I want to deploy a load-balanced multi VM network implementation? Obviously, that requires a little more knowledge. Well, fortunately, and we’ll see this in some of the later modules, as we scroll through these templates– and let’s see if I can find this one here–
611.7
let’s scroll through. Here’s one that creates a load balancer.
623.6
Here’s a load balancer with two network cards connected to two different networks. So these templates provide you a great starting point for not just creating singular objects in Azure, but creating entire collections of objects that are all properly configured to talk to each other. For example, this two VMs with an internal load balancer, if I click on it and then I go to this visualise button, it’s going to show me a visual representation of what that’s going to create. And what you’ll see is that this is a little more elaborate. We’ve got virtual machines, network interfaces, and internal load balancers– this is the internal load balancer over here– connected to storage accounts and networks.
666.3
So there’s a lot more going on than just creating a virtual machine. That’s where the power of these ARM templates actually comes in. GitHub’s a great repository. It’s not the only one. You can also create templates offline if you’re skilled at it. You can store templates directly inside your subscription. For example, you define a template but you don’t want that template out in the public. What do you do with it? Well, within your subscription there’s a templates node where you can actually see templates you’ve uploaded. So these are my corporate templates.

In the last step, you learned about the ARM Template structure. In this step, you will deploy objects in your Azure subscription and learn how to use QuickStart templates

You can leverage GitHub as a resource to build and deploy solutions on Azure. This repo contains all currently available Azure Resource Manager templates contributed by the community.

There is a searchable template index, a contribution guide, a list of template best practices and a Git usage tutorial.

A screenshot of a GitHub page showing one of the Azure Quickstart templates available on the community page. Highlighted are the files contained within, and the README.md file’s text is shown below.

In the next step, we will look at a demo of Azure Resource Manager Templates.

This article is from the free online

Microsoft Future Ready: Fundamentals of DevOps and Azure Pipeline

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now