Last updated: May 2026
Azure Virtual Machines Intermediate AZ-104 ⏱ 11 min read

Azure Spot VMs

Azure Spot VMs let you use Microsoft's unused data centre capacity at up to 90% discount compared to pay-as-you-go prices. The catch is that Azure can reclaim (evict) your Spot VM with just 30 seconds notice when it needs the capacity back. That sounds risky — but for the right workloads, Spot VMs are transformative for cost savings.

What you'll learn How Spot VMs work · Eviction policies · Eviction types (Deallocate vs Delete) · Maximum price setting · When to use Spot VMs · When NOT to use Spot VMs · Handling eviction gracefully · Spot VMs in Scale Sets · Cost savings in practice

How Spot VMs Work

Azure's data centres are never 100% utilised. At any given time, some physical servers have spare capacity. Azure sells this spare capacity at a steep discount as Spot instances. When Azure needs that capacity back for regular customers, your Spot VM gets evicted.

ℹ️
Spot Pricing is Dynamic Spot prices fluctuate based on supply and demand. When a region has lots of spare capacity, Spot prices are very low. When capacity is tight, prices rise. You can check current Spot prices in the Azure Portal under Virtual Machines → Spot pricing history.

Typical Spot Savings

VM SizePay-As-You-GoTypical Spot PriceSavings
Standard_D4s_v5~₹13,000/month~₹1,300–3,900/month70–90%
Standard_E8s_v5~₹26,000/month~₹2,600–7,800/month70–90%
Standard_F8s_v2~₹16,000/month~₹1,600–4,800/month70–90%

Eviction Policies

There are two eviction policies that determine when your Spot VM can be evicted:

Capacity Only (Default)

Your VM is only evicted when Azure needs the capacity back. The Spot price you pay is whatever the current market rate is — it fluctuates, but you pay whatever it is at the time.

Price or Capacity

Your VM is evicted if either: (1) Azure needs the capacity, OR (2) the current Spot price exceeds your maximum price. You set a maximum price you're willing to pay per hour — if Spot prices rise above that, your VM is evicted.

Eviction Types

When a Spot VM is evicted, what actually happens depends on your eviction type setting:

Eviction TypeWhat HappensDisk Preserved?Can Restart?
DeallocateVM is stopped and deallocatedYesYes — when capacity available
DeleteVM and disk are permanently deletedNoNo — must create new VM
💡
Which to Choose? Use Deallocate if you want to preserve the VM's state and restart it when capacity returns. Use Delete for truly stateless workloads — it's cleaner and avoids orphaned disk charges.

Maximum Price Setting

You can optionally set a maximum hourly price you're willing to pay for a Spot VM. If the Spot price rises above this, the VM is evicted.

  • Setting max price to -1 (recommended) means "never evict based on price — only evict if Azure needs capacity." You'll always pay the current market Spot price, whatever it is.
  • Setting a specific price (e.g., ₹5/hour) means you get evicted if price exceeds that. Good for strict budget control.

When to Use Spot VMs

Spot VMs are perfect for any workload that can tolerate interruption and restart from where it left off (or start fresh):

WorkloadWhy Spot Works
Batch data processingProcess data in chunks — restart failed chunks if evicted
CI/CD build agentsBuild fails → just re-trigger the pipeline on a new agent
Video/image renderingRendering jobs can be saved and resumed
Machine learning trainingML frameworks support checkpoint saves — resume from last checkpoint
Dev/test environmentsOccasional interruptions acceptable for non-production
Web crawlers / scrapersStateless — just restart and continue
HPC simulationsCheckpointing allows continuation after interruption

When NOT to Use Spot VMs

WorkloadWhy Spot Fails
Production web serversEviction causes user-facing downtime
DatabasesEviction can cause data corruption or loss
Primary application serversEviction breaks the application for users
Anything with SLA commitmentsNo SLA on Spot VMs — eviction can happen anytime
⚠️
No SLA on Spot VMs Microsoft provides NO uptime SLA for Spot VMs. They can be evicted at any time with 30 seconds notice. Never use Spot for any workload where interruption would cause user impact or data loss.

Handling Eviction Gracefully

Azure gives you a 30-second eviction notice via the Azure Scheduled Events service. Your application can poll this endpoint and react — save progress, drain connections, write checkpoints.

Bash Check for eviction notice from inside the VM
# Poll the Azure metadata service for scheduled events
# Run this in a loop inside your application
curl -H "Metadata:true" \
  "http://169.254.169.254/metadata/scheduledevents?api-version=2020-07-01"

# If you see "Preempt" in the response, eviction is imminent
# Save your work immediately!

Spot VMs in Scale Sets

VM Scale Sets support a mix of regular and Spot VMs — called Mixed Instance Policy. You can configure Scale Sets to use Spot VMs for most instances (cheap) and a few regular VMs as a baseline (always available). This gives you massive cost savings with some baseline availability.

Creating a Spot VM

Azure CLI Create a Spot VM
az vm create \
  --resource-group myResourceGroup \
  --name mySpotVM \
  --image Ubuntu2204 \
  --size Standard_D4s_v5 \
  --priority Spot \
  --eviction-policy Deallocate \
  --max-price -1 \
  --admin-username azureuser \
  --generate-ssh-keys \
  --location centralindia
💡
AZ-104 Exam Tip Know that Spot VMs offer up to 90% discount, can be evicted with 30 seconds notice, have no SLA, support Deallocate or Delete eviction types, and are best for fault-tolerant batch workloads. The exam loves testing what Spot VMs are NOT suitable for.
📝 Practice Questions
Click an option to check your answer. AZ-104 style questions.
Q1. How much notice does Azure give before evicting a Spot VM?
A 5 minutes
B 30 seconds
C 2 minutes
D 24 hours
Q2. Which of the following workloads is MOST suitable for Azure Spot VMs?
A A production e-commerce website
B A primary SQL Server database
C Overnight batch data processing jobs
D A customer-facing REST API
Q3. What happens to the OS disk when a Spot VM is evicted with the "Delete" eviction type?
A The OS disk is preserved as an unattached managed disk
B The OS disk is automatically moved to cold storage
C The OS disk is permanently deleted along with the VM
D The OS disk is automatically snapshotted before deletion
Q4. What does setting max-price to -1 mean when creating a Spot VM?
A The VM is free — no charges apply
B Never evict based on price — only evict when Azure needs capacity
C Use pay-as-you-go pricing instead of Spot pricing
D Cap the hourly price at ₹1
Q5. What SLA does Microsoft provide for Azure Spot VMs?
A 99.9%
B 99%
C 95%
D No SLA — Spot VMs can be evicted at any time
Comments
Disclaimer: RedKite Cloud is an independent educational resource and is not affiliated with, endorsed by, or officially connected to Microsoft Corporation. All product names, logos, and trademarks are property of their respective owners. Content is written independently for educational purposes only.