Using ARM Template to Deploy an Environment in Azure

Daniel Bundor
6 min readJul 30, 2023

--

ARM template (Azure Resource Manager template) is a declarative JSON (Javascript Object Notation) file that can be used to quickly deploy repeatable and modular environments in the Azure cloud. ARM templates help us to codify infrastructures using Infrastructure as Code (Code). We can pass ARM templates to Azure Resource Manager for various types of deployments. ARM templates when deploy, usually find the necessary resource providers in Azure and quickly deploy our environments at various scopes such as a subscription or a resource group. ARM templates provide us repeatable deployments because we are using infrastructure as code (IaC). ARM templates also provide us with the opportunity of doing away with error-prone deployments that include manual orchestrations, configurations as well as the provisioning of resources in the Azure cloud. We can also be able to easily recover our environments by being able to quickly repeat a deployment if we codify a specific environment. ARM templates help us easily automate deployments of different types of resources and environments.

ARM template architecture

Components of ARM Templates

ARM templates are made of various components to include:

  1. Paramaters
  2. Variables
  3. Resources
  4. Outputs

The parameters and variables components are used to pass information to the template. For example, with parameters, these are things that are dynamic that we can pass at runtime of the ARM template deployment such as a Username or a VM SKU that we want to use for the virtual machine deployment that we are running in an ARM template. Variables on the other hand, are a little bit different. They are certainly not dynamic. Variables include things that we hardcode into ARM templates.

The resources component is used to define resources in the template. Resources include resource blocks that we use to outline specific resources we want to deploy in our properties and we can use the parameters and variables in this section of the template to define those properties either dynamically with parameters or hardcoded with variables.

The outputs component is used to return output from the execution of the template. For example, maybe for a virtual machine deployment, we want to get back the public or private IP address. We can use the output section of the template to return the necessary information regarding the public or private IP address of the deployed VM.

A skeleton ARM template

It is important to note that ARM templates cannot be deployed without schema and content version.

At this point, let’s get our hands dirty!

Illustration of our deployment scope

We begin by making our way into the Azure portal and providing the necessary login credentials.

Note: We are using an Azure cloud sandbox since we do not have an independent subscription that would allow us to execute this exercise.

Azure login page (We will provide email or login ID)
Azure login page (Password section)
Sandbox Home page (We have successfully login)

Next, we will be using an ARM template from a raw link stored in GitHub.

A minute portion of the ARM template

Next, we will copy the entire ARM template JSON and make our way back to the Azure portal using the sandbox account.

In the Azure portal, we will use the search box on the tool bar to search Deploy a custom template, and click or select Deploy a custom template.

Searching Deploy a custom template

Next, we will click Build your own template in the editor. The double underlined portion of the below screenshot.

Custom deployment page

Next, we will erase the skeleton template provided by Azure and paste the copied JSON from the raw link copied from GitHub.

The skeleton template

Next, after pasting the copied JSON, we can click save to save the JSON file or ARM template for our deployment.

Note: We can already identify the allocated resources in our deployment on the left pane of the custom template deployment page.

The beginning of the ARM template
The ending of the ARM template

Note: Our template comprises of 10 parameters, 7 variables, and 6 resources, which include a storage account, public IP address, a network security group, virtual network, a network interface card, and a virtual machine.

Next, after clicking save, we move on to provide the necessary project details that will enable us to conclude our deployment including Admin username, Admin Password, and other relevant portions of the project details.

Note: We will keep the resource group at default since we are using a sandbox instead of our personal or authorized account.

Provide relevant project details

Because variables are hardcoded, which means that we set our variable values directly in our code, we can only change our parameters. For example, we can change our Public IP Allocation Method to static and our Public Ip Sku to Standard so that it is secured by default provided by Azure offerings as shown below. We could also change our OS Version as well as the Vm Size, but in our case we will leave it at default since we are using a sandbox account. The Location is automatically set based on the resource group location. We can as well change our Vm name provided we want, but we are not going to change it given our desire to keep it as it is.

Change Public IP Allocation Method to static
Change Public Ip Sku to Standard

We can also visualize the resources that are being deployed by our ARM template by clicking on Visualize on the Custom deployment page.

Resources being deployed

Next, we will click Review + create to provision our deployment pending validation from Azure in making sure that what we are trying to deploy can be deployed.

Click on Review + create

Next, we will click on Create after Review + create and wait for our deployment to become successfully completed.

Click on Create
Our deployment is complete

Next, we can click on Go to resource group to see what resources were deployed.

Our deployed resources

We can verify that our deployment was completed and successful!

Conclusion:

In conclusion, when we click on Create, our deployment sends the ARM template to the Azure Resource Manager, and the Azure Resource Manager will take the template, and send off all the various operations to the appropriate resource providers to deploy all of our resources within the deployed ARM template. When we deploy an ARM template, it takes care of deploying all our allocated resources, and all we have to ensure when we write our ARM template is that we are specifying what resources we want to deploy, and in the order we want to have them deployed since there would be resource dependencies when deploying resources.

--

--