|
1 | 1 | ---
|
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. |
8 | 4 | 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 |
11 | 8 | ---
|
12 | 9 |
|
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. |
14 | 13 |
|
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. |
16 | 15 |
|
17 | 16 | ## Prerequisites
|
18 | 17 |
|
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: |
20 | 19 |
|
21 | 20 | - A host pool with at least one session host.
|
| 21 | + |
22 | 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 | 23 |
|
| 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). |
25 | 25 |
|
26 |
| -## Enable drain mode |
| 26 | +## Enable and disable drain mode for a session host |
27 | 27 |
|
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. |
29 | 29 |
|
30 |
| -### [Portal](#tab/portal) |
| 30 | +### [Azure portal](#tab/portal) |
31 | 31 |
|
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: |
33 | 33 |
|
34 | 34 | 1. Sign in to the [Azure portal](https://portal.azure.com).
|
35 | 35 |
|
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. |
37 | 37 |
|
38 |
| -1. Under **Services**, select **Azure Virtual Desktop**. |
| 38 | +1. From the Azure Virtual Desktop overview page, select **Host pools**. |
39 | 39 |
|
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**. |
41 | 41 |
|
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**. |
43 | 43 |
|
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**. |
45 | 45 |
|
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) |
47 | 47 |
|
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. |
49 | 49 |
|
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. |
53 | 52 |
|
54 | 53 | [!INCLUDE [include-cloud-shell-local-powershell](includes/include-cloud-shell-local-powershell.md)]
|
55 | 54 |
|
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: |
65 | 56 |
|
66 |
| -Update-AzWvdSessionHost @params |
67 |
| -``` |
| 57 | + ```powershell |
| 58 | + $params = @{ |
| 59 | + ResourceGroupName = '<ResourceGroupName>' |
| 60 | + HostPoolName = '<HostPoolName>' |
| 61 | + Name = '<SessionHostName>' |
| 62 | + AllowNewSession = $False |
| 63 | + } |
68 | 64 |
|
69 |
| -3. Run this cmdlet to disable drain mode: |
| 65 | + Update-AzWvdSessionHost @params |
| 66 | + ``` |
70 | 67 |
|
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: |
78 | 69 |
|
79 |
| -Update-AzWvdSessionHost @params |
80 |
| -``` |
| 70 | + ```powershell |
| 71 | + $params = @{ |
| 72 | + ResourceGroupName = '<ResourceGroupName>' |
| 73 | + HostPoolName = '<HostPoolName>' |
| 74 | + Name = '<SessionHostName>' |
| 75 | + AllowNewSession = $True |
| 76 | + } |
81 | 77 |
|
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 | + ``` |
84 | 80 |
|
85 | 81 | ---
|
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