Skip to content

Commit 9131496

Browse files
authored
Merge pull request #266949 from dknappettmsft/patch-1
AVD session host drain mode update
2 parents 90c4030 + 532bff5 commit 9131496

File tree

1 file changed

+45
-55
lines changed

1 file changed

+45
-55
lines changed
Lines changed: 45 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,81 @@
11
---
2-
title: How to use drain mode to isolate session hosts - Azure Virtual Desktop
3-
description: How to use drain mode to isolate session hosts to perform maintenance in Azure Virtual Desktop.
4-
services: virtual-desktop
5-
author: Heidilohr
6-
7-
ms.service: virtual-desktop
2+
title: Drain session hosts for maintenance in Azure Virtual Desktop
3+
description: Learn how to enable drain mode to isolate session hosts for maintenance in Azure Virtual Desktop.
84
ms.topic: how-to
9-
ms.date: 02/09/2024
10-
ms.author: helohr
5+
author: dknappettmsft
6+
ms.author: daknappe
7+
ms.date: 02/23/2024
118
---
129

13-
# Use drain mode to isolate session hosts and apply patches
10+
# Drain session hosts for maintenance in Azure Virtual Desktop
11+
12+
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.
1413

15-
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.
14+
This article shows you how to drain session hosts using the Azure portal or Azure PowerShell.
1615

1716
## Prerequisites
1817

19-
If you're using either the Azure portal or PowerShell method, you'll need the following things:
18+
To drain session hosts, you need:
2019

2120
- A host pool with at least one session host.
21+
2222
- 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).
2423

24+
- 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).
2525

26-
## Enable drain mode
26+
## Enable and disable drain mode for a session host
2727

28-
Here's how to enable drain mode using the Azure portal and PowerShell.
28+
Here's how to enable and disable drain mode for a session host using the Azure portal and PowerShell.
2929

30-
### [Portal](#tab/portal)
30+
### [Azure portal](#tab/portal)
3131

32-
To turn on drain mode in the Azure portal:
32+
To enable drain mode for a session host and block new sessions in the Azure portal:
3333

3434
1. Sign in to the [Azure portal](https://portal.azure.com).
3535

36-
1. Enter **Azure Virtual Desktop** into the search bar.
36+
1. In the search bar, type *Azure Virtual Desktop* and select the matching service entry.
3737

38-
1. Under **Services**, select **Azure Virtual Desktop**.
38+
1. From the Azure Virtual Desktop overview page, select **Host pools**.
3939

40-
1. At the Azure Virtual Desktop page, go the menu on the left side of the window and select **Host pools**.
40+
1. Select the host pool that contains the session host you want to drain, then select **Session hosts**.
4141

42-
1. Select the host pool you want to isolate.
42+
1. Check the box next to the session host you want to enable drain mode, then select **Turn drain mode on**.
4343

44-
1. In the navigation menu, select **Session hosts**.
44+
1. 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**.
4545

46-
1. Next, select the hosts you want to turn on drain mode for, then select **Turn drain mode on**.
46+
### [Azure PowerShell](#tab/powershell)
4747

48-
1. To turn off drain mode, select the host pools that have drain mode turned on, then select **Turn drain mode off**.
48+
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. You'll need to run these commands for every session host for which you want to enable and disable drain.
4949

50-
### [PowerShell](#tab/powershell)
51-
52-
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.
50+
> [!IMPORTANT]
51+
> In the following examples, you'll need to change the `<placeholder>` values for your own.
5352
5453
[!INCLUDE [include-cloud-shell-local-powershell](includes/include-cloud-shell-local-powershell.md)]
5554

56-
2. Run this cmdlet to enable drain mode:
57-
58-
```powershell
59-
$params = @{
60-
ResourceGroupName = "<resourceGroupName>"
61-
HostPoolName = "<hostpoolname>"
62-
Name = "<hostname>"
63-
AllowNewSession = $False
64-
}
55+
2. To enable drain for a session host and block new sessions, run the following command:
6556

66-
Update-AzWvdSessionHost @params
67-
```
57+
```powershell
58+
$params = @{
59+
ResourceGroupName = '<ResourceGroupName>'
60+
HostPoolName = '<HostPoolName>'
61+
Name = '<SessionHostName>'
62+
AllowNewSession = $False
63+
}
6864
69-
3. Run this cmdlet to disable drain mode:
65+
Update-AzWvdSessionHost @params
66+
```
7067

71-
```powershell
72-
$params = @{
73-
ResourceGroupName = "<resourceGroupName>"
74-
HostPoolName = "<hostpoolname>"
75-
Name = "<hostname>"
76-
AllowNewSession = $True
77-
}
68+
3. To disable drain for a session host and allow new sessions, run the following command:
7869

79-
Update-AzWvdSessionHost @params
80-
```
70+
```powershell
71+
$params = @{
72+
ResourceGroupName = '<ResourceGroupName>'
73+
HostPoolName = '<HostPoolName>'
74+
Name = '<SessionHostName>'
75+
AllowNewSession = $True
76+
}
8177
82-
>[!IMPORTANT]
83-
>You'll need to run this command for every session host you're applying the setting to.
78+
Update-AzWvdSessionHost @params
79+
```
8480

8581
---
86-
87-
## Next steps
88-
89-
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).
90-
91-
If you're using the PowerShell method and want to see what else the module can do, check out [Set up the PowerShell module for Azure Virtual Desktop](powershell-module.md) and our [PowerShell reference](/powershell/module/az.desktopvirtualization/).

0 commit comments

Comments
 (0)