AZURE Infra as Code, ARM Template Cheat Sheet
Tags: azure, devops, iac
Published: 2020-12-06 21:23:07

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zcu5dp37ak2n564gxt7q.png)

## 1 ARM Template schema

The first element, by the convention of a template. It contains the location and the schema name along with its version. 
The schema name defines the scope of the template.

| Scope  | Latest Version  | Json Shema |
| --------- | --------- | --------- |
| Resource group | 2019-04-01 | deploymentTemplate.json |
| Subscription | 2018-05-01 | subscriptionDeploymentTemplate.json |
| Management Group | 2019-08-01 | managementGroupDeploymentTemplate.json |
| Tenant | 2019-08-01 | tenantDeploymentTemplate.json |
| Parameter | 2019-04-01 | deploymentTemplate.json |

[Template]( https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax#template-format?WT.mc_id=AZ-MVP-5003620)

## 2 Content version 

Content version is used in template files and parameters files. It let you define versions across your template files. Useful when using linked templates. The format should be <MajorVersion.MinorVersion.BuildNumber> but it's a convention, not a requirement. 

## 3 Metadata
Optional, let you define any property you want to document your template 

## 4 API profile
Optional. Useful if you plan to deploy the template on Azure Cloud and Azure Stack or Azure Gov. API profile ensure that API version of each resource in the template are available in the target environment and you do not have to provide API version at the resource level. 

[API Profile]( https://github.com/Azure/azure-rest-api-specs/tree/master/profile)

## 5 comments

ARM template allows you to comment your code either with a single line comment // or multiline comments with /* */


## 6 parameters

Parameters are the user's inputs. Each parameter is typed (string, int, array, bool, object, secureString and secureObject). You can have a default value (defaultValue), allowed value (allowedValue an array), maximum and minimum length (maxLength and minLength for string and array), maximum and minimum value (maxValue and minValue for int value), and a description through metadata:description. 

[Parameters in ARM templates]( https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-parameters?WT.mc_id=AZ-MVP-5003620)

## 7 functions

This section lets you define your functions in your template. Often these functions are called user-defined functions to avoid confusion with built-in template functions. To create a function, you need to create a namespace and define parameters and output.

[Functions]( https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax#functions?WT.mc_id=AZ-MVP-5003620)

## 8 variables

Variables let you define values and make them available in all other template sections, but not in the parameters section. Values can be constants, a single value, or an expression.

[Variables in ARM template]( https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-variables?WT.mc_id=AZ-MVP-5003620)

## 9 Resources 

The resource section is where you define what you want to deploy. It's an array where you 
define what you need to deploy.
[Resources]( https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax#resources?WT.mc_id=AZ-MVP-5003620)

## 10 Output

The purpose of this section is to return information after the deployment. Each value has a type, the same type as in the parameters section. 

[Outputs in ARM templates]( https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-outputs?tabs=azure-powershell&WT.mc_id=AZ-MVP-5003620)