Oct 02 2020

3 Tips to Deploy Resources Within the Azure Cloud by Using ARM Templates

Microsoft makes it easy to set up cloud components with Azure Resource Manager.

Azure Resource Manager templates are text files created in the JavaScript Object Notation (JSON) format that define what cloud resources to provision within Azure. Once an ARM template is built, an administrator can deploy it to Azure, instructing it to build the resources therein. To follow the steps provided here, you must first have an Azure subscription and have downloaded and installed the Azure command-line interface (CLI) tool.

1. Start by Writing the ARM Template Itself

The first task of deploying resources to Azure is writing the ARM template itself. To get started, download sample prebuilt templates at statetechmag.com/ARM. This template creates an Ubuntu 18.04 Azure virtual machine and all associated resources.

To be clear, the provided ARM template is just an example. An actual template used in a real environment will look different based on the kind of resources the ARM template is deploying. 

2. Validate the ARM Template

After downloading or creating an ARM template for an environment, it’s a good idea to validate it. Validation ensures the template has no bugs or syntax issues and can be successfully deployed to Azure with no errors. 

Using the Azure CLI, validate an ARM template by running the az group deployment validate command as shown below. Be sure to replace yourresourcegroup_name with the name of an actual resource group in your Azure subscription. This command reads the template LinuxVirtualMachine.json and parameters defined in the file LinuxVirtualMachine.parameters.json, which then validates the ARM template and the parameters file:

az group deployment validate --resource-group yourresourcegroup_name --parameters .\LinuxVirtualMachine.parameters.json --template-file .\LinuxVirtualMachine.json

3. Deploy the ARM Template

Using the Azure CLI once again, deploy the Azure resources defined in the template using the az group deployment command again. This time, however, remove the validate command to deploy the Azure resources defined in the ARM template: az group deployment create --resource-group yourresourcegroup_name --parameters .\LinuxVirtualMachine.parameters.json --template-file .\LinuxVirtualMachine.json

This command reads the LinuxVirtualMachine.json ARM template and the LinuxVirtual Machine.parameters.json parameters file. It then replaces all of the parameter placeholders in the ARM template with values in the parameters file and invokes the deployment.

monsitj/Getty Images

Become an Insider

Unlock white papers, personalized recommendations and other premium content for an in-depth look at evolving IT