Azure Resource Manager (ARM) concept - Time & Space Complexity
When working with Azure Resource Manager, it's important to understand how the time to deploy or update resources changes as you add more resources.
We want to know how the number of resources affects the total deployment time.
Analyze the time complexity of deploying multiple resources using an ARM template.
{
"$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 multiple storage accounts as separate resources in one deployment.
Look at what happens repeatedly during deployment.
- Primary operation: Creating or updating each resource via ARM API calls.
- How many times: Once per resource defined in the template.
As you add more resources, the number of API calls grows directly with the number of resources.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The number of operations grows in a straight line with the number of resources.
Time Complexity: O(n)
This means the deployment time grows proportionally with the number of resources you deploy.
[X] Wrong: "Adding more resources won't affect deployment time much because ARM handles everything at once."
[OK] Correct: Each resource requires a separate API call and provisioning step, so more resources mean more work and longer deployment time.
Understanding how deployment time scales with resource count helps you design efficient templates and manage expectations in real projects.
"What if we used nested deployments to group resources? How would that affect the time complexity?"