In this blog post, we’ll explore how to set up an auto-shutdown schedule for virtual machines in Microsoft Azure. This feature is incredibly valuable as it helps reduce cloud workload costs by automatically shutting down VMs when they’re not in use.
For instance, if you know that your company employees typically use virtual machines (VMs) from 9 AM to 5 PM, running these VMs beyond this time can result in unnecessary costs. To manage this, you can configure an auto-shutdown schedule for the VMs and set them to shut down at 5 PM every day automatically. This helps optimize resource usage and reduce expenses.
Auto-shutting down a VM results in the VM being shut down and placed in a stopped or deallocated stage. When a VM is in this state, you won’t incur charges for VM computing. However, it’s important to be aware that you’ll still be responsible for the storage cost associated with the VM, although this cost is generally lower than the compute cost.
If you’re using Azure Virtual Desktop (AVD), you can take advantage of a feature in the host pool called Start VM on connect. This feature will automatically power up a stopped or deallocated virtual machine when a user attempts to connect. This helps optimize resource usage and ensures that VMs are available when users need them.
However, if you are not using Azure Virtual Desktop, you can skip this step and proceed to the following sections of this post.
Contents
Configure Auto shutdown for Azure Virtual Machines
Setting up auto shutdown for an Azure Virtual Machine is a straightforward process. Just follow these steps to configure it:
- Sign in to the Azure Portal.
- Search for Virtual machines.
- Find the Virtual Machine from the list on which you want to enable auto shutdown and click on it.
- Scroll down on the page, and under operations, you will find Auto-shutdown
- Select Enable: On
- Scheduled shutdown: Set when you want to shut down this VM daily.
- Time zone: Set the time zone
- Send notification before auto-shutdown?: Yes
- Webhook URL: Keep Empty
- Email address: This address will receive an email 30 minutes before the machine shuts down. The email will also include the option to postpone the shutdown of the VM.
Here’s an example notification email users may receive before their VMs automatically shut down. You will receive a notification message: Your virtual machine in Azure DevTest Labs will automatically shut down.
It’s worth noting that even though I don’t have any Azure DevTest Lab configured, this email refers to it, which can be just a bug. Hopefully, this may be updated in the future. However, the notification itself is valuable and offers options to postpone the restart of your VM, making it a useful feature for managing your Azure resources.
Email Notification |
---|
Your virtual machine in Azure DevTest Labs will automatically shut down Virtual machine avd-tp-0 (AVDrg) is scheduled to shut down in 30 minutes. You may postpone or skip this instance: Postpone: 1 hour > Postpone: 2 hours > Skip this instance > Note that if you postpone the shutdown, a new notification will be sent 30 minutes prior to the new shutdown time. |
Azure VM Auto shutdown Email notification not received
If you’ve recently set up Azure VM auto-shutdown and provided an email address for notifications but haven’t received a notification yet, make sure to allow at least 30 minutes for the notification to be sent. Otherwise, the schedule will be skipped for the current day and will apply from the next day.
For example, if it’s currently 11:00 AM, and you’ve configured an auto-shutdown for a virtual machine at 11:15 AM, it won’t work for the current day, and you won’t receive an email notification. However, the schedule will be in effect the next day at 11:15, and you can expect to receive an email notification then.
Conclusion
Auto-shutting down virtual machines is a cost-saving strategy that should be utilized in any organization, particularly in development and UAT environments where VMs are not in constant use.
These machines are typically utilized during application development, and there’s no need to incur compute costs outside of office hours. Identify these VMs and set up the auto-shutdown to significantly reduce your monthly bill. This simple step can lead to substantial cost savings.
Thank you for this guide, this works perfect for virtual machines.
But how can I configure this for AVD Session Hosts in a Hostpool?
There I can’t configure the auto shutdown.
Do you have any recommendation for me?
Thank you.