Auto-shutdown helps reduce costs by automatically turning off virtual machines at a specified time. You can configure shutdown using the Azure portal, Azure CLI, PowerShell, or ARM templates.
az vm auto-shutdown \
--resource-group MyResourceGroup \
--name MyVM \
--time 1900 \
--time-zone "Pacific Standard Time" \
--notification-email user@example.com
Replace MyResourceGroup, MyVM, and other parameters with your values.
Set-AzVMAutoShutdown -ResourceGroupName "MyResourceGroup" `
-VMName "MyVM" `
-Time "19:00" `
-TimeZone "Pacific Standard Time" `
-Email "user@example.com"
{
"type": "Microsoft.DevTestLab/schedules",
"name": "[concat(parameters('vmName'), '-shutdown')]",
"apiVersion": "2018-09-01",
"location": "[resourceGroup().location]",
"properties": {
"status": "Enabled",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "1900"
},
"timeZoneId": "Pacific Standard Time",
"notificationSettings": {
"status": "Enabled",
"timeInMinutes": 30,
"webhookUrl": ""
}
},
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', parameters('vmName'))]"
]
}