Subscriptions and management groups in Azure - Time & Space Complexity
We want to understand how the time to manage Azure subscriptions and management groups changes as the number of subscriptions grows.
Specifically, how does organizing and applying policies scale when you add more subscriptions?
Analyze the time complexity of the following operation sequence.
// Assign a policy to each subscription under a management group
foreach (var subscription in managementGroup.Subscriptions)
{
AssignPolicy(subscription, policyDefinition);
}
This sequence assigns a policy to every subscription inside a management group.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Assigning a policy to a subscription via API call.
- How many times: Once per subscription in the management group.
As the number of subscriptions increases, the number of policy assignments grows proportionally.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The operations increase directly with the number of subscriptions.
Time Complexity: O(n)
This means the time to assign policies grows linearly as you add more subscriptions.
[X] Wrong: "Assigning a policy to a management group applies it instantly to all subscriptions without extra time."
[OK] Correct: While assigning at the management group level is one action, the system still processes each subscription, so the total time grows with the number of subscriptions.
Understanding how operations scale with the number of subscriptions helps you design efficient cloud governance and shows you can think about system behavior as it grows.
"What if we assigned a policy only once at the root management group instead of each subscription? How would the time complexity change?"
Practice
Solution
Step 1: Understand the role of subscriptions
Subscriptions in Azure are containers that group resources for billing and access control.Step 2: Differentiate from management groups
Management groups organize subscriptions, not the other way around.Final Answer:
To group cloud resources for billing and access control -> Option AQuick Check:
Subscription = billing and access grouping [OK]
- Confusing subscriptions with management groups
- Thinking subscriptions organize management groups
- Assuming subscriptions apply policies directly
Solution
Step 1: Identify the correct Azure CLI command
The command to create a management group is 'az account management-group create' with the --name parameter.Step 2: Check the options for syntax correctness
az account management-group create --name MyGroup matches the correct syntax; others use incorrect commands or parameters.Final Answer:
az account management-group create --name MyGroup -> Option CQuick Check:
Correct CLI command = az account management-group create --name MyGroup [OK]
- Using 'az group create' which creates resource groups, not management groups
- Incorrect parameter names like --group-name
- Shortened commands like 'az mg create' which don't exist
Solution
Step 1: Understand policy inheritance in management groups
Policies assigned at a management group apply to all child subscriptions automatically.Step 2: Apply this to the given hierarchy
Since both Subscription X and Y are under Management Group A, both inherit the policy.Final Answer:
Both Subscription X and Y inherit the policy -> Option BQuick Check:
Management group policies apply to all child subscriptions [OK]
- Thinking policies apply only to one subscription
- Assuming subscriptions override management group policies
- Believing policies do not inherit down the hierarchy
Solution
Step 1: Recall subscription assignment rules
Each subscription can belong to only one management group at a time.Step 2: Analyze the error cause
If the subscription is already assigned elsewhere, reassigning without removal causes an error.Final Answer:
The subscription is already assigned to another management group -> Option DQuick Check:
One subscription per management group at a time [OK]
- Thinking management groups cannot contain subscriptions
- Believing resource groups are needed before assignment
- Assuming CLI cannot assign subscriptions
Solution
Step 1: Understand management group hierarchy for policy scope
Policies assigned to a management group apply to all its child subscriptions.Step 2: Organize subscriptions to control policy application
By placing S1 and S2 in a management group and assigning the policy there, S3 remains unaffected if outside that group.Final Answer:
Create a management group with S1 and S2 as children, assign the policy there; leave S3 outside -> Option AQuick Check:
Group subscriptions to control policy scope [OK]
- Assigning policy to all subscriptions and trying to exclude one
- Assigning policies individually instead of using groups
- Putting all subscriptions in one group and expecting selective policy
Ready to prove it?
Pass the test and this pattern moves unknown
