What Auto-Shutdown Does
Auto-shutdown deallocates (not deletes) your VM at a scheduled time each day. Deallocating means:
- ✅ Compute billing stops — you no longer pay for CPU/RAM
- ✅ The VM, its OS disk, and data disks are preserved
- ✅ The VM can be manually started again any time
- ⚠️ Storage billing continues — you still pay for the disk(s)
- ⚠️ Public IP may change if dynamic — use static IP if you need the same IP after restart
Deallocate — The VM is removed from hardware. Compute billing stops. This is what auto-shutdown does.
Delete — VM and resources are permanently removed.
Setting Up via Azure Portal
- Go to your VM in the Azure Portal
- In the left menu, scroll to Operations → click Auto-shutdown
- Toggle Enabled to On
- Set the Scheduled shutdown time — e.g., 8:00 PM
- Set the Time zone — select your local timezone (e.g., India Standard Time)
- Optionally configure Notification — see next section
- Click Save
Shutdown Notifications
Auto-shutdown can send you an email or webhook notification 30 minutes before shutdown. This gives you time to save your work or delay the shutdown if you're still using the VM.
Email Notification
In the auto-shutdown settings, under Notification:
- Enable Send notification before auto-shutdown
- Enter your email address
- Azure sends a warning email 30 minutes before shutdown
Webhook Notification
For automated systems, you can provide a webhook URL. Azure sends an HTTP POST to this URL before shutdown — useful for triggering automated save operations or alerting Slack/Teams channels.
Setting Up via CLI
# Get the VM resource ID
VM_ID=$(az vm show \
--resource-group myResourceGroup \
--name myVM \
--query id \
--output tsv)
# Enable auto-shutdown at 20:00 (8 PM) in IST timezone
# Note: time is in UTC format for CLI — IST is UTC+5:30, so 8 PM IST = 14:30 UTC
az rest \
--method put \
--uri "https://management.azure.com/subscriptions/{sub-id}/resourceGroups/myResourceGroup/providers/microsoft.devtestlab/schedules/shutdown-computevm-myVM?api-version=2018-09-15" \
--body '{
"location": "centralindia",
"properties": {
"status": "Enabled",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {"time": "1430"},
"timeZoneId": "India Standard Time",
"targetResourceId": "'$VM_ID'"
}
}'
Auto-Start (Scheduled Start)
Azure doesn't have a built-in "auto-start" equivalent to auto-shutdown. However, you can achieve scheduled starts using:
Option 1 — Azure Automation Runbook
Create an Azure Automation account with a PowerShell runbook that starts the VM. Schedule it to run at your desired start time.
Connect-AzAccount -Identity # Use managed identity
Start-AzVM \
-ResourceGroupName "myResourceGroup" \
-Name "myVM"
Option 2 — Azure Function (Timer Trigger)
Create an Azure Function with a timer trigger that calls the Azure REST API to start the VM at a specific time. Functions are free for the first 1 million executions per month.
Cost Savings Calculation
Let's calculate real savings for a typical dev VM:
| Scenario | Running Hours/Month | Cost (B2s VM) |
|---|---|---|
| No auto-shutdown (24/7) | 730 hours | ~₹2,200 |
| Auto-shutdown at 8 PM, start 8 AM (12 hrs/day) | 365 hours | ~₹1,100 |
| Auto-shutdown at 6 PM, start 9 AM (9 hrs/day) | 270 hours | ~₹810 |
| Auto-shutdown at 5 PM, start 9 AM (8 hrs/day) | 240 hours | ~₹720 |
Just by adding auto-shutdown at 6 PM and starting at 9 AM on workdays, you save roughly ₹1,390/month on a single B2s VM — over ₹16,000/year. For a team with 10 dev VMs, that's ₹1.6 lakh/year in savings.
Best Practices
- Enable on all dev/test VMs by default — Make it a team policy, not optional
- Set up email notifications — 30-minute warning prevents losing unsaved work
- Use static public IPs for dev VMs — Dynamic IPs change after deallocation, which breaks SSH config and scripts
- Never enable auto-shutdown on production VMs — Obvious, but worth stating
- Configure during VM creation — Easier than remembering to add it after
- Pair with Azure Policy — Enforce auto-shutdown on all VMs in dev/test resource groups automatically