Marcel
Marcel That's me: Marcel

Changing the disk type automatically while starting or deallocating a session host / VM for WVD

Changing the disk type automatically while starting or deallocating a session host / VM for WVD

The costs of running virtual machines in Azure summarize the costs of their components like VM type (compute), storage, network, and some other parts. While the spendings for the compute stops after deallocating VMs, Microsoft continues charging for the storage (the virtual disks). These make sense while the disks continue using the underlying storage.

There are three main types of storage for managed disks with different prices: E.g 128 GByte costs between $5.89 to $19.71 per disk per month.

If you have many VMs, the disks' costs become more important while you have to pay for the disk while the VM is running or not.

If you run Windows Virtual Desktops, your session hosts don't run 24/7 (the same happens for test and demo environments). So, you start and stop the virtual machines to your needs. This lowers the compute costs, but the costs for the disks continue. But if a virtual machine is deallocated, the storage performance is unimportant. Why don't we change the disk type to the cheapest after deallocating and bringing it back to a higher performance before starting the VM? That is absolutely possible and can be done through the Azure Portal - or using WVDAdmin.

With the current version of WVDAdmin you can tag a VM / session host to change the disk type on start and after the deallocation. Simply add a tag to the VMs with the name "WVD.AdvDiskType" and one of the following values: - StandardSSD_LRS - Premium_LRS

After this, refresh WVDAdmin, and the disk type changes on start to the named type and goes to standard HDD (the cheapest) after the deallocation.

PS: You can add the tags automatically using the "Custom Tags" tab in WVDAdmin:

Important: Keep in mind that change the disk type on the fly only works in WVDAdmin. If you start/stop a VM in the Azure Portal (or with an autoscaling engine), the disk type will not change.