Automate deployment of resources using ARM templates or Bicep
📘Microsoft Certified: Azure Administrator Associate (AZ-104)
1. Exporting an Existing Deployment as a Template
Azure gives you the option to export a template after you deploy resources. This is helpful when you want to:
- Reuse the same deployment in other environments.
- Understand how Azure creates resources internally.
- Customize or modify a starting template instead of building from scratch.
Where to Export Templates
You can export deployment templates from:
a) Azure Portal → Resource Group → Deployments
Each deployment inside a resource group has details and a JSON template Azure used.
Steps:
- Open Resource group in Azure Portal.
- Click Deployments from the left menu.
- Select a deployment.
- Choose Export template.
This exports the template used during that specific deployment—helpful when you want the exact configuration.
2. Exporting a Resource Group as a Template
Sometimes you want to export the entire resource group as a reusable template.
Azure Portal allows you to export a template that represents the current state of all resources.
Steps:
- Go to Resource group.
- Select Export template.
- Azure generates a JSON template describing the whole infrastructure.
Exam Tip
This export may not always be perfectly deployable because:
- Some properties are read-only.
- Some values cannot be redeployed (for example, unique names, system-generated IDs).
But it is a great starting point for building automated deployments.
3. Converting ARM Templates to Bicep
Microsoft strongly recommends using Bicep, so the exam expects you to know how to:
- Convert JSON ARM templates →
.bicep - Understand the tools used for conversion
You use the Bicep CLI or Azure CLI for this.
4. Decompile ARM JSON to Bicep Using Bicep CLI
The process is called decompilation.
It converts a JSON ARM template to a .bicep file.
Command:
bicep decompile mytemplate.json
This creates:
mytemplate.bicep
Key Notes for Exam:
- Decompilation is not always perfect. You may need to adjust the Bicep file manually.
- It still saves a lot of time compared to writing Bicep from scratch.
5. Convert Templates Using Azure CLI
Azure CLI can also convert templates to Bicep.
Install Bicep via Azure CLI
az bicep install
Decompile a template
az bicep decompile --file mytemplate.json
This is functionally the same as using the Bicep CLI.
6. Export and Convert Templates in Visual Studio Code
Most Azure admins use VS Code because:
- It supports Bicep and ARM JSON.
- It provides IntelliSense, validation, syntax highlighting.
- It can automatically convert templates.
Decompile inside VS Code
Right-click on an ARM JSON template → Decompile to Bicep
(Available if you have the Bicep extension installed.)
7. When You Would Use Exporting or Converting Templates (IT-based scenarios)
Below are appropriate IT-environment scenarios (not physical world analogies):
Scenario 1: Recreate an existing resource group in a test environment
An administrator exports the template from production and redeploys it in a test environment to match configurations.
Scenario 2: Understand how a resource was deployed
A resource may have been deployed by another team member or with a different tool.
Exporting the deployment template allows you to see all settings.
Scenario 3: Migrate from ARM JSON to Bicep
If your organization has older ARM templates, you convert them to Bicep for easier maintenance.
Scenario 4: Create automation pipelines
CI/CD pipelines (e.g., GitHub Actions, Azure DevOps) often require infrastructure as code.
Exporting and converting templates makes it easier to include these in automated deployment pipelines.
8. Limitations to Be Aware of (Exam Focus)
The AZ-104 exam expects you to know what cannot be exported perfectly.
Export Template Limitations
- Not all properties are captured (especially hidden or read-only ones).
- Some values must be changed before redeployment (e.g., resource names).
- Multi-resource dependencies might not appear correctly in large deployments.
Decompilation Limitations
- Bicep output may not always be 100% clean.
- Additional manual editing is often required.
- Decompilation cannot restore the original formatting or variables exactly.
9. Exporting Templates with PowerShell
PowerShell also supports template exporting.
Command to Export a Resource Group Template
Export-AzResourceGroup -ResourceGroupName MyRG -Path "C:\templates"
This exports the current state of all resources in the group as an ARM template.
10. Exam Checklist (What You MUST Remember)
✔ ARM templates are JSON files
✔ Bicep files compile into ARM JSON
✔ Templates can be exported from:
- Resource Group → Export Template
- Deployment History → Export template
✔ Convert JSON → Bicep using:
bicep decompile <file>az bicep decompile
✔ Exported templates may require modifications
✔ Decompilation may not be perfect
✔ Exporting helps reuse and automate deployments
If you understand all sections above, you can answer any exam question on this topic confidently.
