Skip to content

Commit 281a646

Browse files
authored
Merge pull request #271736 from sipastak/avd-start-vm-connect-cli
Start VM on Connect update powershell and add CLI
2 parents 7e2fd29 + 72fb10c commit 281a646

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

articles/virtual-desktop/start-virtual-machine-connect.md

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The time it takes for a user to connect to a session host VM that is powered off
2929
To use Start VM on Connect, make sure you follow these guidelines:
3030

3131
- You can only configure Start VM on Connect on existing host pools. You can't enable it at the same time you create a new host pool.
32+
3233
- The following Remote Desktop clients support Start VM on Connect:
3334
- The [Windows client](./users/connect-windows.md?toc=/azure/virtual-desktop/toc.json&bc=/azure/virtual-desktop/breadcrumb/toc.json) (version 1.2.2061 or later)
3435
- The [Web client](./users/connect-web.md?toc=/azure/virtual-desktop/toc.json&bc=/azure/virtual-desktop/breadcrumb/toc.json)
@@ -37,8 +38,13 @@ To use Start VM on Connect, make sure you follow these guidelines:
3738
- The [Android and Chrome OS client](./users/connect-android-chrome-os.md?toc=/azure/virtual-desktop/toc.json&bc=/azure/virtual-desktop/breadcrumb/toc.json) (version 10.0.10 or later)
3839
- The [Microsoft Store client](./users/connect-microsoft-store.md?toc=/azure/virtual-desktop/toc.json&bc=/azure/virtual-desktop/breadcrumb/toc.json) (version 10.2.2005.0 or later)
3940
- Thin clients listed in [Thin client support](./users/connect-thin-clients.md?toc=/azure/virtual-desktop/toc.json&bc=/azure/virtual-desktop/breadcrumb/toc.json)
41+
4042
- If you want to configure Start VM on Connect using PowerShell, you'll need to have [the Az.DesktopVirtualization PowerShell module](https://www.powershellgallery.com/packages/Az.DesktopVirtualization) (version 2.1.0 or later) installed on the device you use to run the commands.
43+
4144
- You must grant Azure Virtual Desktop access to power on session host VMs, check their status, and report diagnostic information. You must have the `Microsoft.Authorization/roleAssignments/write` permission on your subscriptions in order to assign the role-based access control (RBAC) role for the Azure Virtual Desktop service principal on those subscriptions. This is part of **User Access Administrator** and **Owner** built in roles.
45+
46+
- The Azure account you use to configure Start VM on Connect must have the [Desktop Virtualization Host Pool Contributor](rbac.md#desktop-virtualization-host-pool-contributor) role assigned.
47+
4248
- If you enable Start VM on Connect on a host pool, you must make sure that the host pool name, the names of the session hosts in that host pool, and the resource group name don't have non-ANSI characters. If their names contain non-ANSI characters, then Start VM on Connect won't work as expected.
4349

4450
## Assign the Desktop Virtualization Power On Contributor role with the Azure portal
@@ -53,7 +59,7 @@ To learn how to assign the *Desktop Virtualization Power On Contributor* role to
5359

5460
Now that you've assigned the *Desktop Virtualization Power On Contributor* role to the service principal on your subscriptions, you can configure Start VM on Connect using the Azure portal or PowerShell.
5561

56-
# [Portal](#tab/azure-portal)
62+
# [Azure portal](#tab/azure-portal)
5763

5864
To configure Start VM on Connect using the Azure portal:
5965

@@ -69,27 +75,13 @@ To configure Start VM on Connect using the Azure portal:
6975

7076
2. Select **Save** to apply the settings.
7177

72-
# [PowerShell](#tab/azure-powershell)
78+
# [Azure PowerShell](#tab/azure-powershell)
7379

7480
You need to make sure you have the names of the resource group and host pool you want to configure. To configure Start VM on Connect using PowerShell:
7581

76-
1. Open a PowerShell prompt.
77-
78-
1. Sign in to Azure using the `Connect-AzAccount` cmdlet. For more information, see [Sign in with Azure PowerShell](/powershell/azure/authenticate-azureps)
79-
80-
1. Find the name of the subscription that contains host pools and session host VMs you want to use with Start VM on Connect by listing all that are available to you:
82+
[!INCLUDE [include-cloud-shell-local-powershell](includes/include-cloud-shell-local-powershell.md)]
8183

82-
```powershell
83-
Get-AzSubscription
84-
```
85-
86-
1. Change your current Azure session to use the subscription you identified in the previous step, replacing the value for `-SubscriptionName` with the name or ID of the subscription:
87-
88-
```powershell
89-
Set-AzContext -Subscription "<subscription name or id>"
90-
```
91-
92-
1. To enable or disable Start VM on Connect, do one of the following steps:
84+
2. To enable or disable Start VM on Connect, do one of the following steps:
9385

9486
1. To enable Start VM on Connect, run the following command, replacing the value for `-ResourceGroupName` and `-Name` with your values:
9587

@@ -103,8 +95,36 @@ You need to make sure you have the names of the resource group and host pool you
10395
Update-AzWvdHostPool -ResourceGroupName <resourcegroupname> -Name <hostpoolname> -StartVMOnConnect:$false
10496
```
10597
98+
# [Azure CLI](#tab/azure-cli)
99+
100+
You need to make sure you have the names of the resource group and host pool you want to configure. To configure Start VM on Connect using
101+
102+
[!INCLUDE [include-cloud-shell-local-cli](includes/include-cloud-shell-local-cli.md)]
103+
104+
2. To enable or disable Start VM on Connect, do one of the following steps:
105+
1. To enable Start VM on Connect, run the following command, replacing the value for `--resource-group` and `--name` with your values:
106+
107+
```azurecli
108+
az desktopvirtualization hostpool update \
109+
--resource-group $resourceGroupName \
110+
--name $hostPoolName \
111+
--start-vm-on-connect true
112+
```
113+
114+
1. To disable Start VM on Connect, run the following command, replacing the value for `--resource-group` and `--name` with your values:
115+
116+
```azurecli
117+
az desktopvirtualization hostpool update \
118+
--resource-group $resourceGroupName \
119+
--name $hostPoolName \
120+
--start-vm-on-connect false
121+
```
122+
123+
106124
---
107125
126+
127+
108128
>[!NOTE]
109129
>In pooled host pools, Start VM on Connect will start a VM every five minutes at most. If other users try to sign in during this five-minute period while there aren't any available resources, Start VM on Connect won't start a new VM. Instead, the users trying to sign in will receive an error message that says, "No resources available."
110130

0 commit comments

Comments
 (0)