ARM template resources section in Azure - Time & Space Complexity
When deploying infrastructure with ARM templates, it's important to understand how the deployment time grows as you add more resources.
We want to know: How does adding more resources affect the number of deployment operations?
Analyze the time complexity of deploying multiple resources defined in the ARM template's resources section.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-09-01",
"name": "storageAccount1",
"location": "eastus",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"properties": {}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-09-01",
"name": "storageAccount2",
"location": "eastus",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"properties": {}
}
]
}
This template deploys two storage accounts as separate resources.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Deploying each resource defined in the resources array.
- How many times: Once per resource listed in the resources section.
Each resource requires a separate deployment operation, so as you add more resources, the number of operations grows directly with the number of resources.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 resource deployments |
| 100 | 100 resource deployments |
| 1000 | 1000 resource deployments |
Pattern observation: The number of deployment operations increases linearly as you add more resources.
Time Complexity: O(n)
This means deployment time grows in direct proportion to the number of resources you define.
[X] Wrong: "Adding more resources won't affect deployment time much because Azure deploys everything instantly."
[OK] Correct: Each resource requires its own deployment call and provisioning time, so more resources mean more work and longer deployment.
Understanding how deployment time scales with resource count helps you design efficient templates and estimate deployment durations in real projects.
What if we used nested templates to deploy resources instead? How would that change the time complexity?