-
Notifications
You must be signed in to change notification settings - Fork 1
ARM Templates
With the move to the cloud, many teams have adopted agile development methods. These teams iterate quickly. They need to repeatedly deploy their solutions to the cloud, and know their infrastructure is in a reliable state. As infrastructure has become part of the i terative process, the division between operations and development has disappeared. Teams need to manage infrastructure and application code through a unified process.
To meet these challenges, teams can automate deployments and use the practice of Infrastructure as Code, where required infrastructure is declared using code. The infrastructure code becomes part of the development projects codebase. Just like application code, the infrastructure code in a source repository and versioned. Any one on a team can run the code and deploy similar environments.
There are many benefits to using ARM templates, both JSON and Bicep, for your resource provisioning:
- Repeatable results: ARM templates are idempotent, which means that you can repeatedly deploy the same template and get the same result. The template doesn't duplicate resources.
- Orchestration: When a template deployment is submitted to Resource Manager, the resources in the template are deployed in parallel. This process allows deployments to finish faster. Resource Manager orchestrates these deployments in the correct order if one resource depends on another. How ever when there is the need to deploy multiple types of solutions and components, its safer to orchestrate using the CI/CD tools, and utilize the input and output functionality for better automation accross the deployment.
- Preview: The what-if tool, available in PowerShell and Azure CLI, allows you to preview changes to your environment before template deployment. This tool will detail any creations, modification, and deletions that will be made by your template.
- Testing and Validation: You can use tools like the Bicep linter to check the quality of your templates before deployment. ARM templates submitted to Resource Manager are validated before the deployment process. This validation alerts you to any errors in your template before resource provisioning.
- Modularity: You can break up your templates into smaller components and link them together at deployment.
- CI/CD integration: Your ARM templates can be integrated into multiple CI/CD tools, like Azure DevOps and GitHub Actions. You can use these tools to version templates through source control and build release pipelines.
- Extensibility: With deployment scripts, you can run Bash or PowerShell scripts from within your ARM templates. These scripts perform tasks, like data plane operations, at deployment. Through extensibility, you can use a single ARM template to deploy a complete solution.
Two types of ARM templates are available for use today: JSON templates and Bicep templates.
- JavaScript Object Notation (JSON) is an open-standard file format that multiple languages can use.
- Bicep is a new domain-specific language that was recently developed for authoring ARM templates by using an easier syntax.
You can use either template format for your ARM templates and resource deployments.
To implement Infrastructure as Code for Azure solutions, use Azure Resource Manager (ARM) templates. The templates are JavaScript Object Notation (JSON) files that defines the infrastructure and configurations. The template uses declarative syntax, where a desired state is declared. This removes the need to write the sequence of commands to create a set of resources.
Basics
- Azure Resource Manager templates overview
- Structure and Syntax
- Azure resource providers and types
- Create Resource Manager parameter file
- Define child resource in Azure template
Advanced
Tools
- Azure Resource Manager Template Toolkit (arm-ttk)
- Pester
- Pester Quick Start
- What is Pester and Why Should I Care?
- Deploy resources with Resource Manager templates and Azure PowerShell
- Use deployment scripts in templates
As the JSON syntaks of ARM templates is rather cumbersome to read and author, Microsoft has developed a Domain Specific Language (DSL) for deploying Azure resources declaratively, called Bicep.
Bicep aims to drastically simplify the authoring experience with a cleaner syntax, improved type safety, and better support for
modularity and code re-use. It's a transparent abstraction over ARM and ARM templates, which means anything that can be done in an
ARM Template can be done in Bicep (outside of temporary known limitations).
All resource types, apiVersions, and properties that are valid in an ARM template are equally valid in Bicep on day one (Note: even
if Bicep warns that type information is not available for a resource, it can still be deployed).
Bicep code is transpiled to standard ARM Template JSON files, which effectively treats the ARM Template as an Intermediate Language (IL).

bicep build .\deploy.bicep # -> outputs deploy.json
az bicep decompile --file deploy.json # outputs deploy.bicepThis is a mock repo for testing