Automate deployment of resources using ARM templates or Bicep
📘Microsoft Certified: Azure Administrator Associate (AZ-104)
When working as an Azure Administrator, you will often receive an existing ARM template or Bicep file that already deploys resources. Your job may be to update, extend, or fix these templates to meet new business requirements. The AZ-104 exam expects you to understand how to read, edit, and validate both ARM JSON templates and Bicep files.
1. Why You Need to Modify Existing Templates
Organizations use Infrastructure as Code (IaC) to deploy resources consistently. Over time, requirements change. For example, an existing template might need:
- A new storage account added
- A virtual machine size updated
- Additional tags for cost management
- A parameter renamed or made secure
- A resource removed or replaced
- A module added for better structure
The exam tests your ability to identify what part of the template must be changed and understand how those changes affect deployment.
2. Understanding the Structure Before Modifying
To modify a template, you must understand the basic structure.
ARM Template Structure (JSON)
ARM templates have these core sections:
| Section | Purpose |
|---|---|
| $schema | Points to the JSON schema for template validation |
| contentVersion | Tracks version of the template |
| parameters | Values you can pass during deployment |
| variables | Reusable values defined inside the template |
| resources | Actual Azure resources defined in the template |
| outputs | Values returned after deployment |
Bicep Structure
Bicep is simpler and cleaner:
param→ parametersvar→ variablesresource→ resourcesoutput→ outputs
Example Bicep resource:
resource stg 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: storageName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}
3. Common Modifications You Must Know for the AZ-104 Exam
Below are the most exam-relevant updates you may need to perform.
A. Modify Parameters
1. Add a new parameter
Useful when you want flexibility.
Before
"parameters": {
"location": {
"type": "string"
}
}
After (added new parameter)
"parameters": {
"location": {
"type": "string"
},
"storageSku": {
"type": "string",
"defaultValue": "Standard_LRS"
}
}
2. Change a parameter to a secure parameter
Often used for secrets, passwords, connection strings.
"adminPassword": {
"type": "secureString"
}
Bicep:
param adminPassword securestring
B. Modify Variables
Example: Add a variable for resource naming
var vmName = '${env}-web-vm'
Variables help maintain consistency and reduce repeated code.
C. Modify Resources
This is the most important section for the exam.
You may need to:
1. Change SKU or size
Example: VM size change
Bicep:
hardwareProfile: {
vmSize: 'Standard_DS2_v2'
}
2. Add or remove properties
Example: Adding tags
tags: {
environment: 'production'
owner: 'IT'
}
3. Add a completely new resource
For example, adding a network security group (NSG) to a VNet template:
resource nsg 'Microsoft.Network/networkSecurityGroups@2023-05-01' = {
name: 'web-nsg'
location: location
}
4. Modify dependencies
Some resources depend on others.
In ARM:
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', 'myVnet')]"
]
In Bicep, this is automatic, but you can explicitly declare:
resource vm 'Microsoft.Compute/virtualMachines@2023-07-01' = {
name: 'myVM'
dependsOn: [ nsg ]
}
D. Update Outputs
Useful for retrieving details after deployment, such as:
- Storage account name
- Public IP address
Example:
output publicIpAddress string = publicIp.properties.ipAddress
4. Converting Between ARM and Bicep During Modification
You may receive an ARM template but want to convert it to Bicep to make modifications easier.
Decompile ARM → Bicep
bicep decompile azuredeploy.json
Build Bicep → ARM
bicep build main.bicep
5. Validating Changes Before Deployment
Azure provides tools to check templates after modifications.
A. Validate using Azure CLI
az deployment group validate \
--resource-group RG1 \
--template-file main.bicep
B. Validate using PowerShell
Test-AzResourceGroupDeployment -ResourceGroupName RG1 -TemplateFile main.bicep
C. Use VS Code Bicep/ARM extensions for linting
These tools highlight:
- syntax errors
- missing properties
- wrong API versions
- invalid resource types
6. Testing Modified Templates
After updating the template, deploy it in a test environment:
Azure CLI:
az deployment group create \
--resource-group RG-Test \
--template-file main.bicep
You check for:
- Resource misconfigurations
- Property errors
- Dependency issues
- Naming conflicts
7. Best Practices for Modifying Templates
| Best Practice | Why It Matters |
|---|---|
| Use parameters for all values that may change | Avoid hardcoding |
| Use variables for repeated values | Easier maintenance |
| Use modules in Bicep for large deployments | Cleaner and reusable structure |
| Use latest stable API versions | Avoid outdated resources |
| Add comments to explain changes | Helps teams and future maintenance |
| Validate before deploying | Prevents failed deployments |
8. Exam Tips for This AZ-104 Sub-topic
✔ You do not need to memorize every ARM syntax
✔ You must understand the structure of ARM and Bicep
✔ You should be able to identify where to edit a template
✔ Expect questions like:
- “Where would you add a new parameter?”
- “How do you change a resource size in a Bicep file?”
- “Which part of the template defines dependencies?”
- “How do you convert ARM to Bicep?”
- “How do you validate a modified Bicep file?”
✔ You may see real ARM/Bicep snippets and must choose the correct modification.
Conclusion
Modifying existing ARM templates or Bicep files is a key skill for the AZ-104 exam. Focus on understanding the structure, knowing where to make changes, and validating the template before deployment. Once you understand the basic sections and syntax, modifying templates becomes straightforward and systematic.
