Azure Resource Templates (ARM Templates) are a great way to deploy infrastructure in Microsoft Azure. Microsoft has even made available ready-made templates that can be used and customized. These ARM templates are special JSON files commonly used for Microsoft Azure infrastructure deployment. In the AZ-104 exam, you will want to have a good understanding of Microsoft ARM templates, how they work, and how they can be updated.

What is an Azure Resource Manager Template?

The ARM template in Microsoft Azure is a type of descriptor file that declares what the infrastructure and configuration for Azure resources should look like. It enables admins to describe the infrastructure and configuration they want to build. Once the infrastructure and configuration descriptions are set in the ARM template, Azure will carry out those operations automatically.

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

Why Modify an ARM Template?

Modifying an ARM template allows you to:

  • Customize – You may need to customize your deployments to meet certain requirements or even new requirements as these come along
  • Update – Infrastructure needs to be updated over time. You can modify existing infrastructure without manual intervention by updating your ARM templates
  • Consistency – You may need to modify the template to make sure infrastructure is consistently deployed

Key Concepts and Structure of ARM Templates

Before diving into making modifications to an ARM template, let’s review its structure. A typical ARM template includes the following sections:

  • schema: Defines the location of the JSON schema file that describes the template’s structure
  • contentVersion: Specifies the version of the template
  • parameters: Allows you to pass values during deployment
  • variables: Defines values that are used to simplify template expressions
  • resources: Specifies the resources to deploy or update
  • outputs: Returns values after deployment

Modifying an existing ARM Template

What does the process look like when updating an ARM template?

Download Banner

Understanding the current ARM template configuration before making changes is a good idea. Begin by identifying the current sections, resources, and parameters used. Beginning to update resources in this systematic way helps to avoid mistakes or errors.

Common changes

What are some common changes that are made to ARM templates? These include:

  • Adding or removing resources (virtual networks, etc)
  • Updating resource properties
  • Changing parameter values or adding new parameters

If your modifications require new parameters or changes to existing ones:

  • Add new parameters in the parameters section
  • Update the variables section if needed to accommodate new values

{
“parameters”: {
“newParameter”: {
“type”: “string”,
“defaultValue”: “defaultValue”,
“metadata”: {
“description”: “Description of the new parameter”
}
}
},
“variables”: {
“newVariable”: “[concat(‘value-‘, parameters(‘newParameter’))]”
}
}

Updating the resources section

Update the resources section to reflect your changes. Note the following resources section to add a new virtual network:

{
“resources”: [
{
“type”: “Microsoft.Network/virtualNetworks”,
“apiVersion”: “2020-11-01”,
“name”: “[variables(‘vnetName’)]”,
“location”: “[parameters(‘location’)]”,
“properties”: {
“addressSpace”: {
“addressPrefixes”: [
“[parameters(‘addressPrefix’)]”
]
}
}
}
]
}

Helpful tools

You can use tools like Visual Studio Code with the Azure Resource Manager Tools extension or the Azure portal to validate your template. JSON is not known to be easy to read. So, you want to make sure your JSON syntax is correct, and the template structure is valid.

Using tools like the Azure Resource Manager (ARM) Tools for Visual Studio Code is helpful in modifying your ARM templates and checking syntax. It includes language support and resource auto-completion to help you create Azure Resource Manager templates.

Test your ARM templates

AZ-104: Modify an existing Azure Resource Manager template

Before deploying to production, test your modified template in a development environment. Use the Azure CLI or PowerShell to deploy the template:

az deployment group create –resource-group –template-file

Best Practices modifying ARM Templates

  • Use Parameters and Variables: Utilize parameters and variables to make your templates flexible and reusable
  • Keep Templates Simple: Break down complex templates into smaller templates
  • Version Control: Use version control systems like Git to manage and version template changes
  • Documentation: Document your changes within the template to provide context and help with future modifications

Wrapping up

Understanding ARM templates is an essential skill for the AZ-104 exam. It also helps an Azure administrator in tasks such as modifying an existing ARM template. Using ARM templates, new resources can be added, and existing resources can easily be changed. Remember the points we have covered as you prepare to take the AZ-104 exam. The exam will cover topics related to Azure Resource Templates and how these can be updated.

Read More:

Microsoft Azure Administrator: AZ-104: Interpret an Azure Resource Manager Template or a Bicep file – Part 37

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Rate this post