Common ARM Template Patterns
What you'll learn: You'll recognize typical ARM template structures for frequently deployed Azure resources like VNets, storage accounts, and VMs.
The Core Idea
ARM templates follow predictable patterns for common resources. Just like recipes share similar structures (ingredients, steps, cooking time), Azure resources of the same type share common properties and dependency patterns. Recognizing these patterns helps you write templates faster and troubleshoot more effectively.
Virtual Network (VNet) Pattern
VNets typically include address spaces and subnets. The pattern involves declaring the main VNet resource, then defining subnets as nested properties:
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2023-04-01",
"name": "[parameters('vnetName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": ["10.0.0.0/16"]
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "10.0.1.0/24"
}
}
]
}
}
Storage Account Pattern
Storage accounts require globally unique names and specify a SKU and kind:
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2023-01-01",
"name": "[parameters('storageAccountName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2"
}
Virtual Machine Pattern
VMs have complex dependencies: they need NICs, which need VNets, plus storage or managed disks. This pattern uses dependsOn to enforce proper creation order.
Key Takeaway: Common ARM template patterns for VNets, storage accounts, and VMs provide reusable blueprints that speed up infrastructure development and ensure consistent resource configuration across deployments.