DEV Community

loading...

AZURE Infra as Code, ARM Template Cheat Sheet

Olivier Miossec
Microsoft Azure MVP, Passionate about Cloud and DevOps. Co-organizers of the French PowerShell & DevOps UG . Find me on https://github.com/omiossec Living in Amsterdam, NL
Updated on ・2 min read

Alt Text

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

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 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

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

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

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

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

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

Discussion (0)