Skip to main content
ARM template structure.
A simple slide with the title "ARM template structure" in gray text on a white background. A teal, ribbon-like graphic appears on the left and a small "© Copyright KodeKloud" is at the bottom left.
An Azure Resource Manager (ARM) template is a JSON document that declaratively describes the resources you want to deploy in Azure. ARM templates are composed of several top-level sections that define schema/versioning, input parameters, reusable values, custom functions, the resources to deploy, and outputs returned after deployment. Common top-level sections in an ARM template:
  • "$schema"
  • contentVersion
  • parameters
  • variables
  • functions
  • resources
  • outputs
Of these, "$schema", contentVersion, and resources are required for a valid deployment template. The optional sections (parameters, variables, functions, and outputs) are commonly used to make templates reusable, maintainable, and easier to test.
Required top-level elements include "$schema", contentVersion, and resources. Add parameters, variables, functions, and outputs to make templates reusable and less error-prone.
Top-level sections at a glance

Schema

The "$schema" property points to the JSON schema that defines the ARM template language version and grammar. The schema URL can vary depending on deployment scope (tenant, management group, subscription, or resource group). Use the schema URL that matches your deployment scope and ARM features. Example:

contentVersion

contentVersion is a simple version string you can use for tracking template revisions in source control. The convention "1.0.0.0" is frequently used, but you can adopt any versioning scheme that fits your release workflow. Example:

Parameters

Parameters let you pass values into the template at deployment time. Parameters make templates flexible and reusable across environments (dev/test/prod) without editing the template file. Example parameter definition (validates allowed values, supplies a default, and includes metadata):
  • If a supplied value is not in allowedValues, the deployment fails.
  • If no value is supplied, defaultValue is used.

Variables

Variables are fixed values declared inside the template and referenced throughout it. Use variables to centralize repeated literals (for example, resource name prefixes, tags, or shared values) so you only update them in one place. Example:
Reference variables with the ARM template expression: variables('publicIPAddressName').

Functions

ARM templates support user-defined functions to encapsulate reusable logic or repeated code patterns. Functions accept parameters and return computed values that can be referenced elsewhere in the template. Example user-defined function that returns a string (typically you would compute names or composite values here):
Call the function with the ARM expression style: userspace.VMNameGenerator('alice') (using the ARM template expression syntax).

Resources

The resources array contains all resource objects to be deployed. Each resource object has common properties such as name, type, apiVersion, location, sku (when applicable), tags, and properties. Include every resource you want to create, update, or remove in this array. Example: deploying an App Service plan (references the location parameter):
Best practices:
  • Pin apiVersion to a specific supported version for predictable behavior.
  • Use dependsOn to control creation order where implicit dependencies are not sufficient.
  • Use copy loops and nested templates for repeating or complex deployments.

Outputs

outputs lets a template return values after deployment (for example, resource IDs, hostnames, or connection strings). Outputs are useful when you need to pass values from one deployment to another or display important information to the user. Example:
You can retrieve outputs via deployment commands in the Azure CLI, PowerShell, or the portal.

Summary

Structure your ARM template with a clear separation of concerns:
  • "$schema" for grammar/version,
  • contentVersion for template revision tracking,
  • parameters for external inputs,
  • variables for centralized constants,
  • functions for reusable logic,
  • resources for the actual Azure objects, and
  • outputs for post-deployment information.
This structure makes templates easier to maintain, test, reuse, and reason about across environments. Links and references

Watch Video

Practice Lab