Start course

In this course, I’ll start with an overview of Azure Resource Manager templates. Then I’ll show you how to build a template from scratch and deploy an Azure Storage account with it. Next, I’ll show you how to use a template to deploy a virtual machine, which is a more complicated resource. After that, I’ll explain how to make your templates more usable by adding parameters and variables. Finally, I’ll show you how to make your templates more sophisticated by using functions.

Learning Objectives

  • Describe the structure of Azure Resource Manager templates
  • Build an ARM template and use it to deploy a resource
  • Use an ARM template to deploy a virtual machine
  • Use parameters and variables in an ARM template
  • Use functions in an ARM template

Intended Audience

  • Azure administrators and developers


  • Basic knowledge of Azure Virtual Machines, Azure Storage, and Azure Virtual Networks

Although ARM templates primarily contain configuration details, they can include a surprising number of features you’d normally see in a general-purpose programming language. These are mostly provided by functions. For example, we used the concat function to create a string that was a concatenation of two strings. There are lots of other string functions available too. Here’s a list. The URL ( for this page is in the transcript below.

There are also numeric functions, logical operator functions, comparison functions, and many others. You can even create your own functions if you want. I’m not going to go through all of the available functions, but there’s one in particular that’s very useful to know. It’s called the copyIndex function, and it can help you create multiple copies of a resource.

For example, suppose you need to create three data disks on a virtual machine. You could list all of the details for each data disk like this, but there’s a lot of repetition in there, so it would be good to make it more concise. Also, what if you wanted to make the number of data disks a parameter? How would you list a different number of disks based on the value of the parameter? First, I’ll show you how to do it with three data disks, and then I’ll show you what it would look like if you used a parameter.

In the storageProfile for the VM, add a “copy” element. Then, nested inside the copy element, add the name of the property you’re creating, which is “dataDisks” in this case. Then, add “count” and specify the number of copies you want. We need to create three data disks, so we set the count to “3”. This tells it to loop through the next part three times.

Then add “input” and specify all of the properties that you want to repeat. The most important one in this example is the lun (which means the logical unit number of the disk) because it has to be a different number for every data disk.

Now we’re finally getting to the copyIndex function. We say “copyIndex” and put “dataDisks” in brackets. That tells it the name of the copy block we’re dealing with. It’ll loop through this three times and use the loop index as the value for the lun. The first time, the loop index will be “0”. The second time, it’ll be “1”. And the third time, it’ll be “2”. These last two properties are always the same, so we don’t need to use copyIndex for them.

This copy block will produce exactly the same configuration as if we had typed all three of the data disk configurations manually.

Now, what would make this really useful is if we used a parameter to set the number of data disks. Here’s what the code would look like for that. It has a parameter called “numberOfDataDisks”, and it uses that to set the count for the loop.

That’s it for this introduction to ARM templates. There are lots of other advanced topics that you might want to learn once you’ve used ARM templates for a while, but what we’ve covered here should give you more than enough to get you started.

Please give this course a rating, and if you have any questions or comments, please let us know. Thanks!

About the Author
Learning Paths

Guy launched his first training website in 1995 and he's been helping people learn IT technologies ever since. He has been a sysadmin, instructor, sales engineer, IT manager, and entrepreneur. In his most recent venture, he founded and led a cloud-based training infrastructure company that provided virtual labs for some of the largest software vendors in the world. Guy’s passion is making complex technology easy to understand. His activities outside of work have included riding an elephant and skydiving (although not at the same time).