It's Finally Possible To Hibernate Azure VMs

Most VM-based workloads in Azure are either running 24/7 or are scaled up and down dynamically as load changes. However, there are a class of workloads that fall in between these two scenarios, where you are running machines for reasonable periods, but there are periods where they are not in use and you would like to be able to turn them off during that period, but retaining state is a problem. This could include workloads such as:

  • Virtual Desktop machines where you don’t want to lose any work the user left open
  • Development machines that may have complex workloads that take time to setup
  • Systems with long boot times, or prone to issues at startup that you don’t want to turn off because of this

With the General Availability of VM hibernation, you can now use this feature to suspend a VM, rather than turning it off. This way you can stop paying for the VM, but have it’s state retained so that when it is turned back on, it is in the same state as just before it was turned off. Let’s take a look at how this works.


Before using VM hibernation you need to meet a few criteria

VM Size

The VM must be using a size that supports hibernation. The following SKUs support hibernation for sizes up to 64GB RAM

The following sizes support hibernation for up to 112GB RAM

Disk Size

The VM needs to include an OS disk that is large enough to container the OS, applications and the entire memory of the VM on disk.

Unsupported Features

If your VM uses using any of the following features then it will not support hibernation:

  • Ephemeral OS disks
  • Shared disks
  • Availability Sets
  • Virtual Machine Scale Sets in Uniform orchestration mode are not supported. Virtual Machine Scale Sets in Flexible orchestration mode are supported.
  • Spot VMs
  • Managed images
  • Azure Backup
  • Capacity reservations

Enabling Hibernation

If you are creating a new VM, hibernation can be enabled at the time of creation. When using the portal, there is a tick box to do this:

Enable Hibernation

You can also enable it using the CLI:

az vm create --resource-group myRG --name myVM --image Win2019Datacenter --public-ip-sku Standard --size Standard_D2s_v5 --enable-hibernation true

If you want to enable it on an existing VM then there are two steps you need to do and these need to be done with the VM powered down. First you need to enable hibernation for your VM OS disk:

az disk update --resource-group myResourceGroup --name MyOSDisk --set supportsHibernation=true

Then enable it for the VM:

az vm update --resource-group myResourceGroup --name myVM --enable-hibernation true

You can then start the VM and move on to configuring the OS to use hibernation. The process for this will differ depending on the OS.


For Windows VMs, a new extension called Microsoft.CPlat.Core.WindowsHibernateExtension' will automatically be installed and will configure the OS for hibernation, there is no further work needed.


For Linux VMs, if you create the VM through the portal with hibernation enabled, then the LinuxHibernateExtension extension should already be installed. If you created it using the CLI, or enabled it on an existing machine, you will need to install the extension using this command:

az vm extension set -n LinuxHibernateExtension --publisher Microsoft.CPlat.Core --version 1.0 \    --vm-name MyVm --resource-group MyResourceGroup --enable-auto-upgrade true

Hibernating a VM

Once you have hibernation setup, you can hibernate a VM using the portal or CLI. For the portal, go to the VM page and you should see a new hibernate button.

Hibernate Button

Using the CLI, there is a new extension to the VM Deallocate command:

az vm deallocate --resource-group myResourceGroup --name myVM  --hibernate true

To start the VM again, you can press the start button in the portal or use the Az VM Start command:

az vm start -g MyResourceGroup -n MyVm

Things to be aware of

There are a few things with the way hibernation works that you should be aware of:

  • You must hibernate a VM from the portal or CLI. Using the hibernation feature from the OS will result in the VM still being running and being charged for this.
  • You cannot make changes to a hibernated VM, you would need to stop the VM first
  • As with stopping a VM, there is no assurance that there will be capacity available to start it back up again later

More Details