0
0
Azurecloud~10 mins

Spot VMs for cost savings in Azure - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Spot VMs for cost savings
Request Spot VM
Azure checks capacity
Capacity available?
NoSpot VM denied
Spot VM allocated
Run workload
Preemption event?
YesVM evicted
Workload stops
Workload completes
End
The flow shows requesting a Spot VM, Azure checking capacity, allocating if available, running workload, and possible eviction if capacity is needed.
Execution Sample
Azure
az vm create --name mySpotVM --resource-group myRG --image UbuntuLTS --priority Spot --max-price -1
This command creates a Spot VM in Azure with no max price limit, allowing cost savings but possible eviction.
Process Table
StepActionAzure ResponseVM StateNotes
1Request Spot VM creationCheck capacityPendingAzure checks if Spot capacity is available
2Capacity available?YesAllocatedSpot VM is allocated and starts running
3Run workloadRunningRunningWorkload runs on Spot VM
4Preemption event occursEviction noticeEvictedAzure needs capacity, evicts Spot VM
5Workload stopsVM deallocatedStoppedSpot VM is stopped, workload interrupted
6Request Spot VM creationCheck capacityPendingIf retried, process repeats
7Capacity available?NoDeniedSpot VM creation denied due to no capacity
💡 Execution stops when Spot VM is evicted or creation is denied due to capacity.
Status Tracker
VariableStartAfter Step 2After Step 4After Step 5After Step 7
VM StateNoneAllocatedEvictedStoppedDenied
Azure CapacityUnknownAvailableNeeded ElsewhereNeeded ElsewhereUnavailable
Key Moments - 3 Insights
Why can a Spot VM be evicted even if my workload is running?
Because Azure can reclaim Spot VMs anytime when it needs capacity, as shown in execution_table step 4 where a preemption event causes eviction.
What happens if there is no capacity available when requesting a Spot VM?
The Spot VM creation is denied immediately, as shown in execution_table step 7 where capacity is unavailable and VM state is Denied.
Does setting max-price to -1 guarantee my Spot VM will never be evicted?
No, max-price -1 means you accept any price, but eviction depends on Azure capacity needs, not price, as seen in the eviction event in step 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the VM State after Azure confirms capacity is available?
AAllocated
BPending
CEvicted
DDenied
💡 Hint
Check execution_table row 2 under VM State column.
At which step does the Spot VM get evicted due to capacity needs?
AStep 3
BStep 4
CStep 6
DStep 7
💡 Hint
Look for 'Preemption event occurs' in execution_table.
If Azure capacity is not available, what is the VM State shown in variable_tracker after that step?
AAllocated
BRunning
CDenied
DStopped
💡 Hint
See variable_tracker column 'After Step 7' for VM State.
Concept Snapshot
Spot VMs are low-cost Azure VMs that can be evicted anytime.
Request Spot VM with priority Spot and optional max-price.
Azure allocates if capacity is free; otherwise denies.
Workloads run until eviction (preemption) occurs.
Best for interruptible, flexible workloads to save cost.
Full Transcript
Spot VMs in Azure are special virtual machines offered at a lower price because Azure can reclaim them anytime when it needs capacity. When you request a Spot VM, Azure checks if there is enough capacity. If yes, it allocates the VM and your workload runs. However, if Azure needs the capacity back, it sends an eviction notice and stops the VM, interrupting your workload. If there is no capacity at request time, the Spot VM creation is denied immediately. Setting max-price to -1 means you accept any price, but eviction depends on capacity, not price. Spot VMs are best for workloads that can handle interruptions and want to save money.