iTranslated by AI
Converting a Windows 10 Pro Azure VM into an AVD Session Host
TL;DR
- I want to change a Windows 10 Pro Azure VM into an Azure Virtual Desktop session host
- I was struggling with an issue where SxSStackListenerCheck wouldn't reach Success, but the cause was that I wasn't using Windows Enterprise
- With hibernation + Start VM on Connect, there is no room left for further cost optimization
Introduction
I recently had to lend an environment connected to our internal network to someone outside the company, and for that purpose, I had set up a Windows 10 Pro Azure VM for them to use.
However, I decided that I wanted to use the hibernation feature of Azure Virtual Desktop (AVD) for cost optimization. Since I wanted to be able to carry over the data as is, I decided to convert that Azure VM into a session host.
You might think, "Windows 10, really?" but yeah, well, I'll deal with that eventually.
Requirements for AVD session host
Installing RDAgent and RDAgentBootLoader is required.
Referring to Add session hosts to a host pool and AVD Agent Silent Install Procedure, run commands like the following.
For <RegistrationToken>, please copy the Registration key from Azure Virtual Desktop > Host pool in the Azure Portal.
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RWrmXv -OutFile .\Microsoft.RDInfra.RDAgent.Installer-x64.msi
Start-Process msiexec.exe -Wait -ArgumentList '/I Microsoft.RDInfra.RDAgent.Installer-x64.msi /quiet REGISTRATIONTOKEN=<RegistrationToken>'
Remove-Item .\Microsoft.RDInfra.RDAgent.Installer-x64.msi
Invoke-WebRequest -Uri https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RWrxrH -OutFile .\Microsoft.RDInfra.RDAgentBootLoader.Installer-x64.msi
Start-Process msiexec.exe -Wait -ArgumentList '/I Microsoft.RDInfra.RDAgentBootLoader.Installer-x64.msi /quiet'
Remove-Item .\Microsoft.RDInfra.RDAgentBootLoader.Installer-x64.msi
SxSStackListenerCheck fails to reach Success
Even after installing RDAgent and RDAgentBootLoader, when I checked the session host's Health check status, only SxSStackListenerCheck failed to reach Success.
I tried restarting several times with no luck, but then I found a description in the docs.
The side-by-side stack is only supported on Windows Enterprise or Windows Server SKUs, which means operating systems such as Pro VMs aren't supported. If you don't have an Enterprise or Server SKU, the stack will be installed on your VM but won't be activated, so it won't show up when you run qwinsta in the command line.
Troubleshoot Azure Virtual Desktop agent issues - Azure
So, while ensuring that there are users with appropriate licenses, I swapped the product key and changed it from Windows 10 Pro to Windows 10 Enterprise.
The product key can be found in Key Management Services (KMS) client activation and product keys for Windows Server and Windows, so I'll use "NPPR9-FWDCX-D2C8J-H872K-2YT43" for this instance.
Others
Setting up the fine details.
Scaling plan
Scaling plans are now available for Personal host pools as well. While the nuance is slightly different from "scaling," it basically allows you to start and stop session hosts triggered by user login, logoff, or idle time.
And since "hibernate" was recently added, I'll set it up using that.
Here are some points to watch out for (I actually got stuck on these):
- There are restrictions on Azure VM SKUs.
- Using the v5 series is generally fine.
- It cannot be enabled unless Virtual memory is on the C: drive.
- For Azure VMs with a temporary disk (D:), Virtual memory is set to D: by default. You need to change the setting and restart.
- It gives a clear error:
{"code":"VMExtensionProvisioningError","message":"VM has reported a failure when processing extension 'AzureHibernateExtension' (publisher 'Microsoft.CPlat.Core' and type 'WindowsHibernateExtension'). Error message: 'Page file is in temp disk. Please move it to OS disk to enable hibernation.'. More information on troubleshooting is available at https://aka.ms/vmextensionwindowstroubleshoot. "}. This is quite helpful.
For details, please refer to Hibernation overview - Azure Virtual Machines.
Changing Virtual memory settings
I'll post some screenshots just in case.
These are setting screens from a Windows 11 machine, but they should be roughly the same for Windows 10.
Click on something like "System" in the Control Panel.

Control panel - System
In Windows 11, you'll be redirected to the Settings app, but click on "Advanced system settings."

Settings app - System > About
Then, there are setting items a bit deeper in.
Click "Settings" inside the "Performance" box.

Control panel - System properties
Click "Change" inside "Virtual memory."

Control panel - Performance options
On this screen, it's set to "Automatically -" (manage paging file size for all drives), which is fine, or you could set it to "System managed size" for the C: drive.

Control panel - Virtual memory
If you change the settings, a restart will be required to apply them.
Operation Check
So, when it is successfully hibernated, it looks like this.

Azure Virtual Desktop - session host - hibernated
In this state, it is the same as being deallocated as an Azure VM, and charging for the Azure VM portion stops.
It also supports Start VM on Connect, so if you try to connect the next morning, the Azure VM will start on-demand after waiting a few minutes.
Since it uses hibernation, the applications you had open will—lo and behold—return exactly as they were.
Summary
This might be a rare case, but it might be helpful for those who were using a Windows Pro Azure VM as a temporary jump box and decided, "I might as well convert it to AVD."
For regular Azure VMs, you might use Start/Stop VMs v2 overview for cost optimization, but that doesn't support on-demand starting.
The ability to handle situations like "I think I'll start work a bit early today..." is one of the benefits of AVD's Start VM on Connect.
I'm assuming you have a valid Windows Enterprise license, so it should be fine, but if someone points out that this isn't allowed, I'll correct it.
References
- Licensing for Azure Virtual Desktop
- Add session hosts to a host pool
- AVD Agent Silent Install Procedure
- Troubleshoot Azure Virtual Desktop agent issues - Azure
- Key Management Services (KMS) client activation and product keys for Windows Server and Windows
- Hibernation overview - Azure Virtual Machines
- Start/Stop VMs v2 overview
-
Microsoft x Our Cost Optimization Battle (Revised)
Please check out the slides from when I spoke at an event about cost optimization
- PowerShell Cmdlet to reinstall AVD RdAgent, etc. (April 2024 version)
-
Using VM Hibernation with Scaling Plans for AVD Personal Host Pools
Articles written by zukako-san are also helpful; hibernation is covered in more detail there.
- Power Management in Azure Virtual Desktop Personal Host Pools using Scaling Plans
Update log
- Added tags, etc. - 2024/07/14
- Added
$ProgressPreference = 'SilentlyContinue'- 2024/08/20
Discussion