What is an ARM Template?
An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. It uses declarative syntax, meaning you state what you intend to deploy without having to write the sequence of programming commands to create it.
Saving a Deployment as an ARM Template
Saving a deployment as an ARM template is an effective way to automate resource deployment and ensure consistency across environments. Every time you create a resource or a resource group in Azure, you can download a copy of their Resource Manager templates and parameter files for later use.
To save a deployment as an ARM template, follow the steps below:
- Navigate to the resource group you wish to deploy in the Azure portal.
- Click on the resource group name.
- Click on ‘Deployments’ from the resource group’s left menu.
- Locate the specific deployment you want to save.
- Click ‘Template’ in the deployment’s context blade.
At this point, you’ll see the JSON script. You can review the template details and download both the template and parameter file.
Example of an ARM Template
In a declarative approach, an ARM template can structure resources to deploy in a consistent and repeatable manner. Here is an example of an ARM template to deploy a storage account.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
],
"metadata": {
"description": "Storage Account type"
}
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[concat(uniquestring(resourceGroup().id), 'sa')]",
"apiVersion": "2018-07-01",
"location": "[resourceGroup().location]",
"kind": "StorageV2",
"sku": {
"name": "[parameters('storageAccountType')]"
}
}
]
}
Most importantly, become familiar with using ARM templates, as they automate deployments and ensure their consistency. Simultaneously, they prevent time-consuming errors that may occur when setting up resources manually. Being comfortable with ARM templates is a stepping stone to becoming a proficient Azure administrator.
Practice Test
True or False: ARM templates are JSON files that define the resources that need to be deployed to a resource group in Azure.
- True
Answer: True
Explanation: ARM templates are indeed defined in JSON and outline the resources that need to be deployed for a specific Azure solution.
Which of the following actions can be performed with an ARM template?
- A) Deploy resources
- B) Define resource dependencies
- C) Define parameters and variables
- D) Implement iterative deployments
Answer: All of the above (A, B, C, D)
Explanation: ARM templates are very powerful and allow all such actions to manage Azure resources efficiently.
When using ARM templates for Azure resources, are you required to specify the exact sequence in which the resources should be created?
- No
Answer: No
Explanation: No sequence is required because Azure Resource Manager determines the correct provisioning order of resources based on dependencies that you have declared.
True or False: The ARM templates are idempotent.
- True
Answer: True
Explanation: The idempotent character of ARM templates means you will achieve the same state of deployment no matter how many times you apply it.
Can an ARM template depict the infrastructure for the entire application across all the regions?
- Yes
Answer: Yes
Explanation: An ARM template can define all the deployment for an application, including deployments for different regions.
What is the primary language for writing ARM templates?
- A) Python
- B) JSON
- C) Java
- D) C#
Answer: B) JSON
Explanation: ARM templates are written in JSON (JavaScript Object Notation).
True or False: ARM templates can be used to automate deployment and configuration of Azure resources.
- True
Answer: True
Explanation: One of the primary uses of ARM templates is to automate the deployment and configuration of Azure resources.
Can you parameterize an ARM template to allow flexibility in deployment?
- Yes
Answer: Yes
Explanation: Using parameters in an ARM template makes it possible to customize deployment.
Can debugging and error checking of an ARM template be done prior to deployment?
- Yes
Answer: Yes
Explanation: ARM templates can be validated before deployment, helping catch any errors in the JSON file.
True or False: It is not possible to save a deployment as an ARM template in Azure.
- False
Answer: False
Explanation: A successful deployment can be exported as an ARM template in the Azure portal.
Which Azure service allows you to use ARM templates for deploying resources?
- A) Azure DevOps
- B) Azure Resource Manager
- C) Azure Active Directory
- D) Azure Monitor
Answer: B) Azure Resource Manager
Explanation: The Azure Resource Manager is the service that provides the utilization of ARM templates for deploying resources.
Can you use variables in an ARM template to simplify template?
- Yes
Answer: Yes
Explanation: Using variables in ARM templates can simplify the template and reduce redundancy.
Is it possible to use a single ARM template to manage the lifecycle of the resources in your deployment?
- Yes
Answer: Yes
Explanation: ARM templates can be used not only for deployment but also to manage the lifecycle of the resources, including updates to existing resources.
Can the progress of deployment operations be tracked in an ARM template?
- Yes
Answer: Yes
Explanation: The progress of deployment operations can be examined by using Azure’s activity log.
True or False: An ARM template allows you to deploy and manage resources but not delete them.
- False
Answer: False
Explanation: An ARM template can indeed be used to delete resources. This is typically done via an incremental mode deployment.
Interview Questions
What is an Azure Resource Manager (ARM) template?
ARM template is a JSON file that defines the infrastructure and configuration for your resources. They provide a consistent way of creating, updating, and deleting resources.
How do you save a deployment as an ARM template in Azure Portal?
You can save a deployment as an ARM template from the deployments section of a resource group in Azure portal. There’s an option to download the template for the deployment which saves it as an ARM template.
What command is used in Azure CLI to export the template?
The command
az group export --name
followed by the resource group name is used to export the template.
Is it possible to save a deployment as an ARM template using Azure PowerShell?
Yes, it is, using the command:
Get-AzResourceGroupDeploymentTemplate -DeploymentName YourDeploymentName -ResourceGroupName YourResourceGroupName
Which language is used to write ARM templates?
ARM templates are written in JavaScript Object Notation (JSON).
What are the key sections in the structure of an ARM template?
The key sections are parameters, variables, resources, and outputs.
Is it possible to validate an ARM template before deployment?
Yes, Azure provides options to validate your ARM template before deployment either through Azure portal, Azure CLI, or Azure PowerShell.
Can you add comments to an ARM template?
Yes, you can add comments to your ARM templates, which is especially helpful for documenting the purpose and functionality of the template.
What are parameters in an ARM template?
Parameters in an ARM template enable the customization of the template each time you deploy it, such as providing a unique name for a resource during each deployment.
What is the maximum size of an ARM template?
The maximum size of an ARM template is 4 MB.
How many resources can you deploy at once using an ARM template?
You can deploy up to 800 resources at once using an ARM template.
Can you use ARM templates to deploy resources to Azure Stack?
Yes, ARM Templates are a fundamental part of resource deployment in both Azure and Azure Stack.
Can you manage access to resources in an ARM template?
Yes, you can manage access to resources in ARM templates using role-based access control (RBAC).
Can you run scripts as part of the deployment process with ARM templates?
Yes, you can use the "Microsoft.Resources/deploymentScripts" resource type to run scripts as part of the deployment process.
Can you deploy an ARM template directly from a GitHub repository?
Yes, an ARM template can be deployed directly from a GitHub repository or from any publicly accessible URI.