Skip to content

Commit fb53755

Browse files
authored
Merge pull request #266013 from sipastak/avd-drain-mode
AVD drain mode
2 parents 8596054 + ef4e5d4 commit fb53755

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

articles/virtual-desktop/drain-mode.md

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,84 @@ author: Heidilohr
66

77
ms.service: virtual-desktop
88
ms.topic: how-to
9-
ms.date: 04/14/2021
9+
ms.date: 02/09/2024
1010
ms.author: helohr
1111
---
1212

1313
# Use drain mode to isolate session hosts and apply patches
1414

1515
Drain mode isolates a session host when you want to apply patches and do maintenance without disrupting user sessions. When isolated, the session host won't accept new user sessions. Any new connections will be redirected to the next available session host. Existing connections in the session host will keep working until the user signs out or the administrator ends the session. When the session host is in drain mode, admins can also remotely connect to the server without going through the Azure Virtual Desktop service. You can apply this setting to both pooled and personal desktops.
1616

17-
## Set drain mode using the Azure portal
17+
## Prerequisites
18+
19+
If you're using either the Azure portal or PowerShell method, you'll need the following things:
20+
21+
- A host pool with at least one session host.
22+
- An Azure account assigned the [Desktop Virtualization Session Host Operator](rbac.md#desktop-virtualization-session-host-operator) role.
23+
- If you want to use Azure PowerShell locally, see [Use Azure CLI and Azure PowerShell with Azure Virtual Desktop](cli-powershell.md) to make sure you have the [Az.DesktopVirtualization](/powershell/module/az.desktopvirtualization) PowerShell module installed. Alternatively, use the [Azure Cloud Shell](../cloud-shell/overview.md).
24+
25+
26+
## Enable drain mode
27+
28+
Here's how to enable drain mode using the Azure portal and PowerShell.
29+
30+
### [Portal](#tab/portal)
1831

1932
To turn on drain mode in the Azure portal:
2033

21-
1. Open the Azure portal and go to the host pool you want to isolate.
34+
1. Sign in to the [Azure portal](https://portal.azure.com).
35+
36+
1. Enter **Azure Virtual Desktop** into the search bar.
2237

23-
2. In the navigation menu, select **Session hosts**.
38+
1. Under **Services**, select **Azure Virtual Desktop**.
2439

25-
3. Next, select the hosts you want to turn on drain mode for, then select **Turn drain mode on**.
40+
1. At the Azure Virtual Desktop page, go the menu on the left side of the window and select **Host pools**.
2641

27-
4. To turn off drain mode, select the host pools that have drain mode turned on, then select **Turn drain mode off**.
42+
1. Select the host pool you want to isolate.
2843

29-
## Set drain mode using PowerShell
44+
1. In the navigation menu, select **Session hosts**.
45+
46+
1. Next, select the hosts you want to turn on drain mode for, then select **Turn drain mode on**.
47+
48+
1. To turn off drain mode, select the host pools that have drain mode turned on, then select **Turn drain mode off**.
49+
50+
### [PowerShell](#tab/powershell)
3051

3152
You can set drain mode in PowerShell with the *AllowNewSessions* parameter, which is part of the [Update-AzWvdSessionhost](/powershell/module/az.desktopvirtualization/update-azwvdsessionhost) command.
3253

33-
Run this cmdlet to enable drain mode:
54+
[!INCLUDE [include-cloud-shell-local-powershell](includes/include-cloud-shell-local-powershell.md)]
55+
56+
2. Run this cmdlet to enable drain mode:
3457

3558
```powershell
36-
Update-AzWvdSessionHost -ResourceGroupName <resourceGroupName> -HostPoolName <hostpoolname> -Name <hostname> -AllowNewSession:$False
59+
$params = @{
60+
ResourceGroupName = "<resourceGroupName>"
61+
HostPoolName = "<hostpoolname>"
62+
Name = "<hostname>"
63+
AllowNewSession = $False
64+
}
65+
66+
Update-AzWvdSessionHost @params
3767
```
3868

39-
Run this cmdlet to disable drain mode:
69+
3. Run this cmdlet to disable drain mode:
4070

4171
```powershell
42-
Update-AzWvdSessionHost -ResourceGroupName <resourceGroupName> -HostPoolName <hostpoolname> -Name <hostname> -AllowNewSession:$True
72+
$params = @{
73+
ResourceGroupName = "<resourceGroupName>"
74+
HostPoolName = "<hostpoolname>"
75+
Name = "<hostname>"
76+
AllowNewSession = $True
77+
}
78+
79+
Update-AzWvdSessionHost @params
4380
```
4481

4582
>[!IMPORTANT]
4683
>You'll need to run this command for every session host you're applying the setting to.
4784
85+
---
86+
4887
## Next steps
4988

5089
If you want to learn more about the Azure portal for Azure Virtual Desktop, check out [our tutorials](create-host-pools-azure-marketplace.md). If you're already familiar with the basics, check out some of the other features you can use with the Azure portal, such as [MSIX app attach](app-attach-azure-portal.md) and [Azure Advisor](../advisor/advisor-overview.md).

0 commit comments

Comments
 (0)