Introduction to Azure Resource Manager Templates

Introduction to Azure Resource Manager Templates

Azure resource manager (ARM) is the deployment and management service provided by Azure. It allows you to create, update or delete the Azure resources.

In this article let’s have a look at some basic concepts around Azure Resource Manager.

What is Azure Resource Manager ?

When you interact with Azure using any mode (CLI, PowerShell, Portal, REST APIs, Client SDKs), the request is received by Azure resource manager.

The ARM then authenticates and authorizes the request. If user is valid, then it hands over the request to appropriate Azure service. The Azure service then performs the requested action.

We can imagine now how important the resource manager is. That is why is is replicated across regions, across availability zones. It is never taken down. Because if it is taken down, you will not be able to do anything in Azure.

Key Terms

Some of the important terms to revise before we proceed further:

Resources

An Azure resource is any item that is available on Azure. e.g. virtual machines, storage accounts, app services, etc.

Resource Groups

This is a logical container that can be used for organizing your resources based on what seems to be most logical for your organization and applications.

e.g. you may have a resource groups which logically contains all the resource required for mobile app and another resource group for holding resource required for web site.

Resource Providers

These are services that provides Azure resources. You can see full list of resource providers at this page.

Resource Manager Template (ARM Template)

Resource manager template or more commonly called as ARM template is a JSON document, where you describe (or declare) which all resources you want.

Please note that you do not need to provide the sequence of actions which should be performed. So you just specify “what” you need, without specifying “how” to get it or create it. This syntax is refereed to as “declarative syntax“.

Azure Scopes

There are four levels of scope in Azure, Management Groups, Subscriptions, resource groups and resources.

We already know what are resource groups and resources. We also know what is azure subscription, it is required to get access to Azure for managing resources.

Suppose your organization has multiple Azure subscriptions. Now, you want to control their access. For ex. you may want IT department to grant rights to create new resources. You may want the developers to deploy the application and run few queries. You have option to set the access rights individually on each subscription, but we know it is going to be tedious and tiresome.

Alternatively, an easy way is to organize your subscriptions under management groups. Then you can assign access rights to azure management groups and easily manage the access rights.

Template File Syntax

A template file is a JSON document which declares, which resources should be created. You can write template expressions in the template file.

There are 5 different building blocks of a template file:

Parameters

We can have parameters in the ARM template. The parameters may include certain configuration values.

e.g. the pricing tier in dev environment may be standard (S1) while the pricing tier in UAT environment may be P1 and in production it may be even higher. If we send the pricing tier as parameter then we can use same script to deploy the application on different environments.

Variables

Same as in other programming languages, variables allows you to define the values and reuse them in the script

Functions

There are two types of functions, standard template functions and user defined functions.

Standard template functions are provided by Azure resource manager.

If required, we can write our own functions, (user defined function) to simplify some things or extend standard functions.

Resources

We need to specify the resources we want to deploy.

Outputs

These are return values from the deployed resources

Deployment Process

We know that ARM template is nothing but a JSON document. When we try to deploy the template, the Azure Resource Manager tries to convert this document into a REST request.

Quickstart Templates

We do not need to start writing templates from scratch. There are a lot of quick start templates available and it may be easy and quick to extend them.

When we are in Azure portal, we can create resources in the portal using portal UI, and then we can go to resource and select Export Template, to get the JSON document.

I hope this article has provided you enough information to get you started on the ARM templates. Do comment and let me know thoughts.

Leave a Reply