Automate Deployments with ARM Templates and Bicep: Parameters, Variables, Modules, What-If and Template Specs

Microsoft Certified Azure Administrator Associate AZ 103 60 min min read Updated: Nov 17, 2026 Intermediate
Automate Deployments with ARM Templates and Bicep: Parameters, Variables, Modules, What-If and Template Specs
Intermediate Topic 3 of 3

Why Templates?

  • Same result every time (idempotent)
  • Faster than clicking and easy to review in Git
  • Rebuild an environment or create dev, test and prod copies

ARM Template Structure (JSON)

json { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "storageName": { "type": "string" } }, "variables": {}, "resources": [{ "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2023-05-01", "name": "[parameters('storageName')]", "location": "[resourceGroup().location]", "sku": { "name": "Standard_LRS" }, "kind": "StorageV2" }], "outputs": { "id": { "type": "string", "value": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageName'))]" } } }

The Same in Bicep

bicep param storageName string param location string = resourceGroup().location resource sa 'Microsoft.Storage/storageAccounts@2023-05-01' = { name: storageName location: location sku: { name: 'Standard_LRS' } kind: 'StorageV2' } output id string = sa.id

Bicep is shorter and easier to read, and it compiles to ARM JSON. Use az bicep decompile to convert JSON to Bicep.

Deploy

bash az group create -n rg-iac -l centralindia az deployment group what-if -g rg-iac -f main.bicep -p storageName=stiac482 az deployment group create -g rg-iac -f main.bicep -p storageName=stiac482 az deployment group list -g rg-iac -o table
powershell New-AzResourceGroupDeployment -ResourceGroupName rg-iac -TemplateFile main.bicep -storageName stiac482 -WhatIf New-AzResourceGroupDeployment -ResourceGroupName rg-iac -TemplateFile main.bicep -storageName stiac482
  • what-if shows what would be created, changed or deleted before you apply
  • Incremental mode (default) adds or updates and leaves other resources alone. Complete mode deletes resources not in the template. Be careful
  • Deployments appear under Deployments in the resource group, with errors

Export from Existing Resources

bash az group export -n rg-demo > exported.json az bicep decompile --file exported.jso

Exported templates are a starting point. Clean them and add parameters before reuse.

Modules and Template Specs

bicep module net 'modules/vnet.bicep' = { name: 'vnet-deploy' params: { vnetName: 'vnet-app', addressPrefix: '10.20.0.0/16' } }
  • Modules split big templates into reusable parts
  • Template specs store versioned templates in Azure that you can share with RBAC
  • Pass secrets as secure parameters or use Key Vault references. Never hard-code passwords

Practice

  1. Write a Bicep file for a storage account and deploy it
  2. Run what-if after changing the SKU
  3. Export a resource group and decompile it
  4. Create a module for a virtual network

Conclusion

Templates make Azure repeatable. Use Bicep or ARM, parameters for values, what-if before deploying, modules for reuse and template specs to share.

Quick Summary: why; ARM; Bicep; deploy; export; modules; specs.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators