ARM TEMPLATE STRUCTURE AND CONSIDERATIONS

To gain a better understanding of the ARM template components, you first need to understand specific considerations for creating an ARM template. The first few considerations that you are going to look at are the template limits. The Azure ARM templates have specifically defined size restrictions for its components. The maximum template size is 1 MB. You usually won’t ever exceed the limits but it is always good to keep this information in mind. What 1 MB size means is that we are referring to the final state of the template after all of the components like iterative resource definitions, values for variables and parameters have been added to it.

The size limit for each parameter file is 64 KB. Before we dive deeper into these, let us see how we can publish an Azure ARM template and how the template and parameter JSON files are deployed.

When you deploy an Azure ARM template, there are two files that are deployed – the Azure ARM template and the parameter file.

Back in the portal where I have an existing Virtual Machine, you can see that this is what its Template file would look like.

And along with that, it also has the parameters file.

You can see other ways to deploy such as CLI, PowerShell, .NET and Ruby. But for now, we will focus on template and parameters file.

As you can see, you can also download the Template and Parameters file. So, click on download and it will download a zip file. Open it.

There are multiple files in the zip file but what we are interested in are the template.json and parameters.json file. Open both these files in VS Code.

Both these files are designed to deploy a single template. The template file contains all the resources whereas the parameter file contains all the parameters required to launch the template. So, this is a common structure of an Azure ARM template.

Beside the limits that were mentioned earlier you are also limited to:

  • 256 parameters
  • 256 variables
  • 800 resources (including copy count)
  • 64 output values
  • 24,576 characters in a template expression

You can exceed some template limits by using a nested template which I will be talking about later on.

To reduce the number of parameters, variables or outputs, you can also combine several values into an object.

Just like there are limitations to the templates, there are also some considerations that should be taken while naming resources as well.

There are three types of resource names in Resource Manager:

  • Azure Resource names that must be generic
  • Azure Resource names that must be unique
  • Azure Resource names that are not required to be unique but you can choose to provide a name for it that will help you identify it based on context.

This means that the name of your VM should be unique within the subscription but can be generic across the board. So, you can have a VM with the name DemoVM in one Azure subscription and a VM with the same name (DemoVM) in another Azure subscription.

By naming your resource, it should also signify the particular resource you are using, your Azure’s subscription ID and other details along with that. To keep things organized, it is better for organizations and teams to adopt a generally accepted naming convention so that it’s easier for all team members to manage the templates.