Jul 07 2020
Cloud

How 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 be sure you have an Azure subscription and have downloaded and installed the Azure command-line interface (CLI) tool.

1. Write the ARM Template

The first task of deploying resources to Azure is writing the ARM template itself. To get started, download a sample prebuilt template at biztechmag.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 here. Be sure to first replace your_resource_group_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 your_resource_group_name --parameters .\LinuxVirtualMachine.parameters.json --template-file .\LinuxVirtualMachine.json

3. Deploy the ARM Template

Using the Azure CLI again, deploy the Azure resources defined in the template using 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 your_resource_group_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 place holders in the ARM template with values in the parameters file and invokes the deployment.

artisteer/Getty Images
Close

See How Your Peers Are Moving Forward in the Cloud

New research from CDW can help you build on your success and take the next step.