An overview of ARM templates for Azure resource deployment

0
11

Infrastructure as code transforms cloud resources into programmable objects that admins can describe, configure and deploy via code. This can speed up deployment, improve consistency, facilitate configuration reuse and provide an audit trail of changes.

Microsoft supports IaC through Azure Resource Manager (ARM) templates. To get started with these templates, users need to be familiar with the basic properties, syntax, development techniques and deployment methods.

Template format

ARM is the primary administration tool within the Azure platform. ARM templates have five core properties:

  1. readable descriptions of Azure resource properties and configuration, which are written in JSON syntax and can include four elements.
  2. parameters
  3. variables
  4. resources
  5. outputs

As Microsoft documentation points out, a skeleton template has the following structure, where the items in quotes are the key elements:

{
    “$schema”: “http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#”,
    “contentVersion”: “”,
    “parameters”: {  },
    “variables”: {  },
    “functions”: [  ],
    “resources”: [  ],
    “outputs”: {  }
}

A functional template has properties within each element, for example:

 “variables”: {
        “<variable-name>”: “<variable-value>”,
        “<variable-object-name>”: {
            <variable-complex-type-value>
        },
        “<variable-object-name>”: {
            “copy”: [
                {
                    “name”: “<name-of-array-property>”,
                    “count”: <number-of-iterations>,
                    “input”: {
                        <properties-to-repeat>
                    }
                }
            ]
        }

There are limits to template size and complexity, but most users are unlikely to encounter them. Templates can be no larger than 1 MB, with each parameter file limited to 64 KB. A template can have up to 256 parameters and variables, as well as 64 output values.

Develop and deploy

Since ARM templates consist of nothing but JSON-formatted text, enterprises can use any text editor, preferably one with JSON format highlighting, to develop them.

One popular option is Visual Studio Code, a free, open source editor that features Microsoft’s IntelliSense highlighting and autocompletion, embedded debugger and integrated git support. Developers who use Visual Studio 2017 can write templates via the tool’s built-in support for Azure development.

Those who prefer to work in a web UI can develop templates in the Azure portal, which provides an editor and interface to enter parameter values and trigger deployments.

Users can also choose the no-code route and create templates via an Azure feature that exports existing resources into a template to clone them. If they deployed resources as part of a Resource Group, admins can navigate to the group in the Azure portal and select Automation Script. This causes ARM to evaluate the resources and output a template. As with all code generators, the process isn’t perfect and could include errors that require cleanup.

There are numerous other ways to deploy ARM templates, including through:

  • Azure CLI
  • Azure PowerShell
  • Azure Cloud Shell
  • ARM portal

Other uses

Templates help maintain consistency across an Azure environment, particularly in hybrid or multi-cloud scenarios. Templates can also enforce role-based access controls through role assignments, such as owner, contributor or reader, to a user, group or application as a parameter.

Enterprises can also use ARM templates to automate the deployment and configuration of virtually any Azure resource — Microsoft offers over 700 QuickStart templates to customize.



Source link

LEAVE A REPLY