ARM Template 101 MS

Template Advantages

  • Improves the consistency, the structure, format in the template is the same regardless of tool
  • Help express deployments that are complex
  • Reduces manual errors
  • Are code, IAC, infrastructure as code, version and evolution over time
  • Reuse and link-able, small templates and combine then

Template Schema

JSON, data stored as obj in text, key=value, each key is a str where the value can be:

  • Str
  • Number
  • Bool exp
  • List of val
  • Obj (other key-val pair)
    "$schema": "",​
    "contentVersion": "",​
    "parameters": {},​
    "variables": {},​
    "functions": [],​
    "resources": [],​
    "outputs": {}​
schemaJepplocation of sch. that describes version of lang.
contentVersionJeppcan provide any value, i. e, next (major/min)
parameters*NAval’s provided when deploy is done or executed to customize
variablesNAval’s used as JSON pieces to simplify exp
functionsNAUDF that are available in temp
resourcesJeppr types for deploy/update in a rg
outputsNareturn values

*parameters limit 256

Template Parameters

QuickStart Templates

More 1

Functional testing

Formatting does help but it is still a single block of text that doesn’t have an actual testing framework, so testing really comes down to performing a deployment and seeing what it creates. If used as part of a wider suite of tests, then the test process should be:

Deploy to a test environment, possibly a dev/test subscription in Azure
Deploy code and application tests
Execute tests
Report results

If all the tests return ‘success’ then the template is, by definition, valid.

Basic testing

PowerShell function


it will take your template, parse it and check that it is syntactically correct as well as validating that you meet requirements such as not hitting quote limits before you deploy.

Defining dependencies

Deploy resources in a specific order, dependsOn section, reference function (use an account key from a storage account which may not be known at build time)

More 2
  • ARM templates for deploy, updating and deleting (JSON-ish)
  • Functions for dynamic temp and UDF, User Defined Functions (best for chaining built-in functions ):

  • Nested templates, you can create a library of modules that do specific tasks, and then call these from your top-level template. This is good for reuse since often we create the same again and again.
  • Deploy:
  • Resource groups, creates your resources in a specific resource group.
  • New-AzResourceGroupDeployment
  • Subscriptions, for creating resource groups
  • New-AzSubscriptionDeployment
  • Management groups, deploy resources that apply to multiple subscriptions (RBAC or custom)
  • New-AzManagementGroupDeployment
  • Deploy mode
  • Default incremental:
  • – Create any r that does not exist in the rg
  • – Update any r with new configuration if new (if required props support this)
  • – Ignore any r that is not part of the template
  • Complete:
  • – Rg will have exactly the same as the template (best for mirror of template and where no manual change is to be done!!!!)
  • Test template before deploy

More 3, IAC, Infrastructure as code