Azure CLI and Cloud Shell - Time & Space Complexity
We want to understand how the time to run Azure CLI commands in Cloud Shell changes as we do more work.
Specifically, how does adding more commands or resources affect the total time?
Analyze the time complexity of running multiple Azure CLI commands in Cloud Shell.
az group create --name MyResourceGroup --location eastus
az vm create --resource-group MyResourceGroup --name MyVM1 --image UbuntuLTS
az vm create --resource-group MyResourceGroup --name MyVM2 --image UbuntuLTS
az vm create --resource-group MyResourceGroup --name MyVM3 --image UbuntuLTS
This sequence creates a resource group and then creates three virtual machines inside it.
Look at what happens multiple times:
- Primary operation: Creating a virtual machine with
az vm create. - How many times: Once per VM, here 3 times.
Each VM creation takes roughly the same time, so total time grows as we add more VMs.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 VM create commands + 1 group create |
| 100 | 100 VM create commands + 1 group create |
| 1000 | 1000 VM create commands + 1 group create |
Pattern observation: The total operations increase directly with the number of VMs created.
Time Complexity: O(n)
This means the time grows in a straight line as you add more virtual machines to create.
[X] Wrong: "Running many VM create commands in Cloud Shell takes the same time as running one."
[OK] Correct: Each VM creation is a separate operation that takes time, so total time adds up as you create more VMs.
Understanding how command sequences scale helps you plan and explain cloud automation tasks clearly and confidently.
"What if we ran VM creation commands in parallel instead of one after another? How would the time complexity change?"