|
| 1 | +--- |
| 2 | +author: abell |
| 3 | +ms.service: azure-bastion |
| 4 | +ms.topic: include |
| 5 | +ms.date: 03/06/2026 |
| 6 | +ms.author: abell |
| 7 | +--- |
| 8 | +When a user connects to a Windows VM via RDP, they must have rights on the target VM. If the user isn't a local administrator, add the user to the Remote Desktop Users group on the target VM. |
| 9 | + |
| 10 | +1. Sign in to your Azure account using `az login`. If you have more than one subscription, you can view them using `az account list` and select the subscription containing your Bastion resource using `az account set --subscription "<subscription ID>"`. |
| 11 | + |
| 12 | +1. To connect via RDP, use the following example. |
| 13 | + |
| 14 | + ```azurecli |
| 15 | + az network bastion rdp --name "<BastionName>" --resource-group "<ResourceGroupName>" --target-resource-id "<VMResourceId>" |
| 16 | + ``` |
| 17 | + |
| 18 | +1. After running the command, you're prompted to input your credentials. You can use either a local username and password, or your Microsoft Entra credentials. Once you sign in to your target VM, the native client on your computer opens up with your VM session via **MSTSC**. |
| 19 | + |
| 20 | + > [!IMPORTANT] |
| 21 | + > Remote connection to VMs that are joined to Microsoft Entra ID is allowed only from Windows 10 or later PCs that are Microsoft Entra registered (starting with Windows 10 20H1), Microsoft Entra joined, or Microsoft Entra hybrid joined to the *same* directory as the VM. |
| 22 | +
|
| 23 | +#### Specify authentication method |
| 24 | + |
| 25 | +Optionally, you can also specify the authentication method as part of the command. |
| 26 | + |
| 27 | +* **Microsoft Entra authentication:** For Windows 10 version 20H2+, Windows 11 21H2+, and Windows Server 2022, use `--enable-mfa`. For more information, see [az network bastion rdp - optional parameters](/cli/azure/network/bastion?#az-network-bastion-rdp(bastion)-optional-parameters). |
| 28 | + |
| 29 | +#### Specify a custom port |
| 30 | + |
| 31 | +You can specify a custom port when you connect to a Windows VM via RDP. |
| 32 | + |
| 33 | +One scenario where this could be especially useful would be connecting to a Windows VM via port 22. This is a potential workaround for the limitation with the *az network bastion ssh* command, which can't be used by a Windows native client to connect to a Windows VM. |
| 34 | + |
| 35 | +To specify a custom port, include the field **--resource-port** in the sign-in command, as shown in the following example. |
| 36 | + |
| 37 | +```azurecli |
| 38 | +az network bastion rdp --name "<BastionName>" --resource-group "<ResourceGroupName>" --target-resource-id "<VMResourceId>" --resource-port "22" |
| 39 | +``` |
| 40 | + |
| 41 | +#### RDP to a Windows VM IP address |
| 42 | + |
| 43 | +You can also connect to a VM private IP address, instead of the resource ID. Microsoft Entra authentication, and custom ports and protocols aren't supported when using this type of connection. For more information about IP-based connections, see [Connect to a VM - IP address](../articles/bastion/connect-ip-address.md). |
| 44 | + |
| 45 | +Using the `az network bastion` command, replace `--target-resource-id` with `--target-ip-address` and the specified IP address to connect to your VM. |
| 46 | + |
| 47 | +```azurecli |
| 48 | +az network bastion rdp --name "<BastionName>" --resource-group "<ResourceGroupName>" --target-ip-address "<VMIPAddress>" |
| 49 | +``` |
0 commit comments