Azure Virtual Machines (VMs) are a powerful tool for running applications, hosting desktops, and performing various tasks in the cloud. However, the cost of running VMs can add up quickly, especially if they are left running when not in use. Microsoft has introduced a new feature called VM Hibernation, which allows you to save costs by hibernating your VMs when they are not needed. In this blog post, we will explore the benefits of VM Hibernation and how you can use it to optimize your Azure costs.
![](https://i0.wp.com/askaresh.com/wp-content/uploads/2024/05/image-24.png?resize=490%2C216&ssl=1)
What is VM Hibernation
VM Hibernation is a cost-saving feature that allows you to deallocate a VM while preserving its in-memory state. When a VM is hibernated, you don’t pay for the compute costs associated with the VM. Instead, you only pay for the storage and networking resources associated with the VM. This means you can save a significant amount of money on your Azure bill by hibernating VMs when they are not in use. Obviously this wont work on its own you will have to intergrate this further with Scaling Plans & Azure Automation.
Use Cases for VM Hibernation
Category | Description |
---|---|
Virtual Desktops | If you use Azure Virtual Desktop to provide virtual desktops (Personal Only) to your employees, you can use VM Hibernation to save costs during non-business hours. By hibernating the VMs after business hours and resuming them the next morning, you can avoid paying for compute resources when they are not needed. |
Dev/Test Environments | If you have development or testing environments that are not used 24/7, you can use VM Hibernation to save costs. By hibernating the VMs when they are not in use, you can avoid paying for compute resources that are not needed. |
Prewarmed VMs | If you have applications that have long initialization times due to memory components, you can use VM Hibernation to save costs. By bringing up the apps and hibernating the VMs, you can quickly start the “prewarmed” VMs when needed, with the applications up and running in the desired state. |
How to Enable Hibernation
Enabling hibernation is straightforward and can be done using various tools like Azure Portal, PowerShell, CLI, ARM, SDKs, and APIs. etc. I will be demonstrating within the Azure Portal:
- Create a Host Pool – Select Personal
- Under the Host Pool creation ensure you have Personal selected as this doesn’t work for Pooled
![](https://i0.wp.com/askaresh.com/wp-content/uploads/2024/05/image-26.png?resize=490%2C89&ssl=1)
- Under Host Pools –> Virtual Machine –> Select Hibernate
![](https://i0.wp.com/askaresh.com/wp-content/uploads/2024/05/image-25.png?resize=490%2C325&ssl=1)
Hibernate is only available for personal host pools. For more information, see Hibernation in virtual machines.
Configuring Scaling Plans
To take full advantage of VM Hibernation, you can configure scaling plans for your VMs. Scaling plans allow you to automatically hibernate VMs based on a schedule or based on user activity.
- Start VM on Connect – Ensure that is “Yes“
- Configure Hibernation Settings
- Define hibernation after a user session disconnects or logs off for a configurable period.
- Assign the Scaling Plan
- Apply the scaling plan to one or more personal host pools.
![](https://i0.wp.com/askaresh.com/wp-content/uploads/2024/05/image-27.png?resize=490%2C197&ssl=1)
Reference Links
Following are the list of helpful links:
Description | Links |
---|---|
Hibernation support now available for Azure Virtual Desktop | Hibernation support now available for Azure Virtual Desktop | Azure Virtual Desktop Blog (microsoft.com) |
Cost Optimization for General Purpose VMs using Hibernation now Generally Available | Cost Optimization for General Purpose VMs using Hibernation now Generally Available – Microsoft Community Hub |
VM Hibernation is a powerful cost-saving feature that can help you optimize your Azure costs. By hibernating VMs when they are not in use, you can save a significant amount of money on your Azure bill. Whether you are using VMs for virtual desktops, dev/test environments, or prewarmed VMs, VM Hibernation can help you save costs without sacrificing performance or availability. Do give it a try in your enivornment and see how much you can save?
Thanks,
Aresh Sarkari
One Response to “Optimize Your Azure Costs with VM Hibernation – Cost saving for Azure Virtual Desktop”