- Azure Resource Manager Templates Quick Start Guide
- Ritesh Modi
- 580字
- 2021-07-02 12:59:35
ARM template structure
ARM templates have six top-level elements:
- schema
- contentVersion
- parameters
- variables
- resources
- outputs
Here's a typical template without any meaningful data:

Let's take a look at each of these elements:
- schema: Defines the grammar, scope, and constraints for elements that are legal and can be used within the template. It helps to ensure that only elements that will keep the template well-defined and valid are allowed, otherwise it will generate an error. The schema also provides the structure for complete ARM templates, including all resources. The value for the schema is an URI that can be navigated to and it is collection of Resource schema URI's. Each resource has its own schema and they all are referred as sub-schemas. One example is a schema for a virtual machine. The schema for virtual machines is defined at https://schema.management.azure.com/schemas/2017-07-01-preview/CloudSimple.PrivateCloudIaaS.json#/resourceDefinitions/virtualMachines, and this URI is mentioned within the master schema URI. It is mandatory to have this section in ARM templates.
- contentVersion: Provides a means of assigning the version number to the template. A template can evolve over time due to feature enhancements or bug fixes. contentVersion helps in creating multiple versions of the same template. This is similar to version control for code using Azure DevOps or GitHub. For ARM templates, a four-part string identifier acts as version number. contentVersion is used while having parent-child relationship between linked templates. We will go through the linked template in Chapter 3, Understanding Core Elements of ARM Templates, of this book. It is mandatory to have this section in ARM templates.
- parameters: This section provides us with the capability to accept values from users and help customize the template. It helps to increase the overall reusability of the template. We will look at parameters in greater detail in the Parameters section of this chapter. The parameters section accepts a JSON object as its value. This JSON object can contain multiple parameter definitions.
- variables: Provides ability to define a value once and reuse it multiple times within the template. This helps in writing maintainable and bug-free templates. Again, we will look at variables in the Variables section. The variables section accepts a JSON object as its value. This JSON object can contain multiple variable definitions.
- resources: This section is the core and main element of an ARM template. It is an optional element in the template structure. All resources and their configurations are declaratively defined here. When an ARM template is deployed, the resources section creates defined resources and configures them according to given specifications. Almost all of the chapters will focus on resources section to a great extent. The resources section accepts a JSON array as its value. This JSON array can contain multiple resource definitions. Square brackets, [], in JSON denote an array, while curly brackets, {}, denote a JSON object.
- outputs: This section provides the ability to return or output values from templates to the user. This helps in finding the status of template execution and getting valuable information that is otherwise difficult to find and navigate. Chapter 3, Understanding Core Elements of ARM Templates, discusses outputs in greater detail. The objects section accepts a JSON object as its value. This JSON object can contain multiple output definitions.
The preceding template structure cannot be deployed because it does not have resources defined within the mandatory resources section. At least one resource should be defined for a template to be deployable.
推薦閱讀
- 每天5分鐘玩轉Kubernetes
- Windows Server 2012 Hyper-V:Deploying the Hyper-V Enterprise Server Virtualization Platform
- Social Media Mining with R
- 發布!設計與部署穩定的分布式系統(第2版)
- 大學計算機應用基礎實踐教程(Windows 7+Office 2013)
- BPEL and Java Cookbook
- Extending Puppet
- 深入Linux內核架構與底層原理(第2版)
- 巧學活用Windows 7
- 嵌入式實時操作系統:RT-Thread設計與實現
- Mobile First Design with HTML5 and CSS3
- Windows 7案例教程
- 注冊表應用完全DIY
- Windows 7實戰從入門到精通
- Windows 7實戰從入門到精通(超值版)