Azure Resource Manager (ARM) Template Structure (01) – Schema Element

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

In developing an understanding of the Azure ARM template, there are two main areas that I advocate covering. Its STRUCTURE and SYNTAX. A basic ARM template structure contains the following sections (or elements):

[code language=”bash”]
{
"$schema": "",
"contentVersion": "",
"parameters": { },
"variables": { },
"functions": { },
"resources": [ ],
"outputs": { }
}
[/code]

As we can see, there are six elements. Each element has properties that we can set (usually in a key/value pair). Of the six elements, only three are actually required in every template (Schema, Content Version and Resources). The other four elements (Parameters, Variables, Functions and Outputs) are optional but are highly recommended to create a flexible and easily reusable ARM template. We’ll be covering each element in this series starting with this post that covers the schema element.

SCHEMA

  • This element should point to the location of the JSON schema file that describes the version of the template language.
  • This schema file is used by editing tools that have the “intellisense” feature (like Visual Studio Code and other versions of Visual Studio) to provide useful capabilities like “code completion”, “content assistance” and “code hinting”
    • In other words, the editing tool can help you to auto-complete your syntax, lets you know when something is wrong with your template and what is wrong because it can compare your syntax with the schema file
    • You can read more about “intellisense” here: https://code.visualstudio.com/docs/editor/intellisense
    • This is one of the reasons why we want to use a proper tool like Visual studio code when editing our ARM templates rather than PowerShell ISE or notepad
  •  Which URL to use?

    • As a general advise, it’s best to stick with the top level schema file specified in the example below
    • This will pull in the proper version of all the child schemas. Microsoft updates the child schemas so all your existing templates don’t have to be updated.
    • It is worth noting that multiple API versions are supported in the child schemas to support “backward compatibility” (this will be discussed further when we cover the “resources” element.
    • Other available versions can be found here: https://github.com/Azure/azure-resource-manager-schemas/tree/master/schemas
      • Go to the above URL
      • Press t to enter the [GitHub File Finder]
      • Type DeploymentTemplate

[code language=”bash”]
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
[/code]

  • DEMO

    • Show a demo of a template that has a schema definition with wrong syntax
    • Show a demo of a template that has no schema definition with wrong syntax


 

 

 

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Azure logging and auditing series
Architecture

Azure Logging/Auditing Series (1) – Activity Logs

Azure logging and auditing play a critical role in the security and compliance strategy of any serious organization.  Collecting detailed information on events that happened

Do You Want To Boost Your Business?

drop us a line and keep in touch