How to Auto shutdown Microsoft Azure Virtual Machine

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 cut down on cloud workload costs by automatically shutting down VMs when they’re not in use.

For instance, if you’re aware 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 automatically shut down at 5 PM every day. This helps optimize resource usage and reduce expenses.

Auto-shutting down a VM not only results in the VM being shut down but also places it in a “stopped” or “deallocated” stage. When a VM is in this state, you won’t incur charges for VM computing. 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 compared to 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 to it. 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.

Start VM on Connect
Start VM on connect

Configure Auto shutdown on Azure VM

Setting up auto shutdown for an Azure Virtual Machine is a straightforward process. Just follow these steps to configure it:

  • Login on Microsoft 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
Auto shutdown Microsoft Azure Virtual Machine
  • Select Enable: On
  • Scheduled shutdown: Set the time when you want to shutdown this VM every day.
  • Time zone: Set the time zone
  • Send notification before auto-shutdown?: Yes
  • Webhook URL: Keep Empty
  • Email address: Email will be sent to this email address 30 minutes before the machine will shutdown. You will also have the option in the email to postpone the shutdown of the VM.

Here’s an example notification email that users may receive before their VMs automatically shut down. The notification message will read, “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 a bit misleading. 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.
Your virtual machine in Azure DevTest Labs will automatically shut down
Your virtual machine in Azure DevTest Labs will automatically shut down

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 for the next day at 11:15, and you can expect to receive an email notification then.

Conclusion

Auto shutdown of virtual machines is a cost-saving strategy that should be employed in any organization, particularly when dealing with 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 for them outside of office hours. To reduce your monthly bill significantly, identify these VMs and set up auto shutdown. This simple step can lead to substantial cost savings.

READ NEXT

Leave a Comment