Modifying an ARM template
ARM templates are used to define infrastructure that needs to be deployed in Azure, which is also often referred to as IaC. One of the benefits of ARM templates is the ability to deploy resources rapidly via code with a level of consistency as opposed to an Azure engineer needing to deploy resources via the Azure portal, which might introduce misconfigurations when repeating tasks. It is also useful to view deployment history.
ARM templates make use of the JavaScript Object Notation (JSON) format to define the resources. To deploy ARM templates, there are two JSON files of importance:
- Template file: This is the main file and has sections to define parameters, variables, user-defined functions, resources, and outputs.
- Parameters file: This file can be on its own and linked to the template file, which is usually done when there are many parameters used in complex deployments.
The following is how the ARM template schema looks when empty:
{
“$schema”:”http://schema.management.azure.com/ schemas/2019-04-01/deploymentTemplate.json#”,
“contentVersion”: “”,
“parameters”: {},
“variables”: {},
“functions”: [],
“resources”: [],
“outputs”: {}
}
Microsoft also has a range of predefined ARM templates that can be downloaded from GitHub and can be used in deployments directly or can be modified to suit the organizational requirements before deployment.
Tip
You can download Microsoft’s Visual Studio Code application and the ARM tools required for free to view and edit ARM templates.
Now that we understand at a high-level what ARM templates are used for, let’s go ahead and start modifying an ARM template. We are going to modify an existing ARM template that is used to create a resource group. Our goal is to modify the template to deploy the resource group in North Europe instead of West Europe.
First, let’s have a look at the template file. Under the resources section we have the following:
- Type: This is where we specify the resource type; in this instance, it is going to be a resource group.
- ApiVersion: This isthe application programmable interface (API) version of the resource.
- Location: This is where the resource group and resources will be located and it is specified under the name parameter in the parameters file.
- Name: This isthe name of the resource; this is specified under the name parameter in the parameters file.
- Copy: This is acopy loop that can be used to create multiple instances, but for our example, we are going to deploy only one resource group for now, which includes the name and count variables.
- Properties: None specified.
- Tags: This is where we reference the resource tags from theparameters file.

Figure 9.1 – Resource group ARM template
Next, let’s look at the parameters file. We have the following configuration under the parameters section:
- resourceGroups: This is where we provide additional information regarding the resource group itself. This is where we specify the name of the resource group and the location.
- resourceTags: This is where we specify the resource tags for the resource group; in this example, we are going to create three values, Environment, Managed By, and Deployed By.

Figure 9.2 – Resource group parameters file
Now that we understand the two templates in more detail, we will only need to change the parameters file to change the deployment region. To do this, we will modify the parameters ARM template and change the location from westeurope to northeurope.
The following screenshot shows the change made under the location parameter:

Figure 9.3 – Changed location from westeurope to northeurope
Now that we have understood how ARM templates work and how to modify a template, let’s go ahead and configure a virtual hard disk (VHD) via an ARM template.
In this section, we had a look at the ARM template structure and how to change the resource location via the ARM template.
We encourage you to read up further by using the following links based on Azure ARM templates: