Drain session hosts for maintenance in Azure Virtual Desktop
Drain mode enables you to isolate a session host when you want to perform maintenance without disruption to service. When a session host is set to drain, it won't accept new user sessions. Any new connections will be redirected to the next available session host. Existing connections to the session host will remain active until the user signs out or an administrator ends the session. Once there aren't any sessions remaining on the session host, you can perform the maintenance you need. Administrators can still remotely connect to the server directly without going through the Azure Virtual Desktop service.
This article shows you how to drain session hosts using the Azure portal or Azure PowerShell.
Prerequisites
To drain session hosts, you need:
A host pool with at least one session host.
An Azure account assigned the Desktop Virtualization Session Host Operator role.
If you want to use Azure PowerShell locally, see Use Azure CLI and Azure PowerShell with Azure Virtual Desktop to make sure you have the Az.DesktopVirtualization PowerShell module installed. Alternatively, use the Azure Cloud Shell.
Enable and disable drain mode for a session host
Here's how to enable and disable drain mode for a session host using the Azure portal and PowerShell.
To enable drain mode for a session host and block new sessions in the Azure portal:
Sign in to the Azure portal.
In the search bar, type Azure Virtual Desktop and select the matching service entry.
From the Azure Virtual Desktop overview page, select Host pools.
Select the host pool that contains the session host you want to drain, then select Session hosts.
Check the box next to the session host you want to enable drain mode, then select Turn drain mode on.
When you're ready to allow new connections to the session host, check the box next to the session host you want to disable drain mode, then select Turn drain mode off.