Deploying Resources to Azure using Azure Resource Manager Templates - Part #1

A component provisioned in Azure can contain a set of resources, say for example a Virtual Machine in Azure can have components such as Storage Accounts, Virtual Networks, IP address etc. And most of the times you may want to manage, deploy and delete these interdependent resources as a single entity. Azure Resource Manager(ARM) will help you to work with these resources in a single, coordinated operation.

ARM supports various tools for interacting with its management layer, the most used ones include Azure CLI, Azure Powershell, REST APIs, and Azure Cloud Shell. The portal gets the newly released functionalities with 180 days of the initial release.

The tools interact with the Azure Resource Manager API, which then passes it to the Resource Manager Service to perform the authentication and authorization of the request. Once this is completed, the Resource Manager then routes the request to the appropriate service for performing the requested operation.

Source: docs.microsoft.com

Glossary

  • Resource: is a manageable item in Azure. Typical examples include web app, database, IP address, virtual machine etc
  • Resource Group: is a container that holds the resources. A resource can belong only on one resource group. It is possible to add/delete resources from a resource group at any time and is also possible to move from one group to another. Also, it can reside in different regions too
  • Resource Provider: A resource provider offers a set of operations and resources for working with an Azure service. Examples include Microsoft.Compute, Microsoft.Web, Microsoft.Storage.
  • Resource Manager Template: is a file in JSON format which contains a declarative syntax for defining the infrastructure as well as configuration for your solution. This file will help you to deploy your resources repeatedly and in a consistent manner.

ARM Template Format


Given below is the barebone format for the template and of the keys among it, only $schema and contentVersion is mandatory

  • $schema: specifies the location of the schema file which defines the version of the template language
  • contentVersion: specifies the version of the template file. You can give any number in there which can be used to document the changes made to the template
  • parameters: specifies the values that can be provided during deployment
  • variables: values that are used in the template for simplifying language expressions in the template
  • functions: user-defined functions available in the template
  • resources: Resources that are going to be created/updated during the deployment
  • outputs: values that can be returned after the deployment
{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "",
    "parameters": {  },
    "variables": {  },
    "functions": {  },
    "resources": [  ],
    "outputs": {  }
}

Sample Template File

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.1",
    "parameters": {
        “resourceGroupName": {
            "type": "string"
        },
        "resourceGroupLocation": {
            "type": "string"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Resources/resourceGroups",
            "apiVersion": "2018-05-01",
            "location": "[parameters('resourceGroupLocation')]",
            "name": "[parameters('resourceGroupName')]",
            "properties": {}
        }
    ],
    "outputs": {}
}


These can be deployed using various tools such as Azure Powershell, Azure CLI, Azure Portal/Cloud Shell, REST APIs. In the next post, I will show you how to use Azure CLI for doing the deployment.


No Comments

Add a Comment

Recent Posts