Reading Azure Resource Manager Templates
ARM templates declare resources in JSON. This lesson explains the template elements, expressions and dependencies so that templates can be read confidently.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the top-level elements of an ARM template.
- Explain template expressions and common functions.
- Explain how dependencies control deployment order.
Declarative deployment with Azure Resource Manager
Azure Resource Manager is the deployment and management service for Azure: the portal, the Azure CLI, Azure PowerShell and SDKs all send requests to it. A template is declarative: it describes the desired end state rather than the steps, and Resource Manager works out the order, deploys resources in parallel where possible and is idempotent, so deploying the same template twice produces the same result.
Template elements
An ARM template has the following top-level elements. Only $schema, contentVersion and resources are required.
| Element | Purpose |
|---|---|
| $schema | The JSON schema, which also indicates the deployment scope (resource group, subscription, management group or tenant) |
| contentVersion | A version number for the template, such as 1.0.0.0 |
| parameters | Values supplied at deployment, with type, defaultValue, allowedValues, minValue, maxValue, minLength, maxLength |
| variables | Values computed in the template, usually from parameters and functions |
| functions | User-defined functions |
| resources | The resources to deploy, each with type, apiVersion, name, location, properties and optional dependsOn |
| outputs | Values returned after deployment, such as a resource ID or IP address |
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageName": { "type": "string", "minLength": 3, "maxLength": 24 },
"skuName": { "type": "string", "defaultValue": "Standard_LRS",
"allowedValues": [ "Standard_LRS", "Standard_GRS" ] }
},
"variables": { "location": "[resourceGroup().location]" },
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2023-05-01",
"name": "[parameters('storageName')]",
"location": "[variables('location')]",
"sku": { "name": "[parameters('skuName')]" },
"kind": "StorageV2",
"properties": { "minimumTlsVersion": "TLS1_2" }
}
],
"outputs": {
"blobEndpoint": { "type": "string",
"value": "[reference(parameters('storageName')).primaryEndpoints.blob]" }
}
}The following diagram shows an ARM template excerpt and how it behaves when given a VM size that the template does not allow.

Template elements
Expressions, functions and dependencies
Values in square brackets are template expressions evaluated at deployment. Common functions are parameters() and variables(); resourceGroup() and subscription() for context such as location and ID; concat(), format() and uniqueString() for names; resourceId() to build a resource's ID; and reference() to read a deployed resource's runtime properties.
When one resource needs another, such as a network interface that needs a subnet, the dependent resource lists the other in dependsOn (by name or resourceId()), and Resource Manager deploys them in order. Using reference() or listKeys() on a resource in the same template also implies a dependency. Parameters of type securestring and secureObject are not logged or returned in deployment history, which is how passwords are passed.
Reading template expressions
Reading a template
A template has a parameter vmSize with allowedValues ["Standard_B2s", "Standard_D2s_v5"] and no default, a variable nicName set to [concat(parameters('vmName'), '-nic')], and a VM resource with dependsOn containing [resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]. What happens if an administrator deploys it with vmSize Standard_D4s_v5, and in what order are the resources created?
The deployment fails validation before any resource is created, because Standard_D4s_v5 is not in the allowed values; the administrator must choose one of the two listed sizes. With a valid size, Resource Manager creates the network interface named, for example, vm1-nic first and then the VM, because the VM's dependsOn references the NIC.
Which three elements are required in every ARM template?
Show answer
$schema, contentVersion and resources.
Exam Tips
Remember for the exam
- Parameters are supplied by the deployer; variables are computed in the template.
- dependsOn controls deployment order; reference() implies a dependency.
- allowedValues violations fail validation before deployment.
- Use securestring for passwords so they are not logged.