| title | Connect a VNet to a Virtual WAN hub - PowerShell |
|---|---|
| titleSuffix | Azure Virtual WAN |
| description | Learn how to connect a VNet to a Virtual WAN hub using PowerShell. |
| author | cherylmc |
| ms.service | azure-virtual-wan |
| ms.custom | devx-track-azurepowershell |
| ms.topic | how-to |
| ms.date | 06/15/2023 |
| ms.author | cherylmc |
This article helps you connect your virtual network to your virtual hub using PowerShell. You can also use Azure portal to complete this task. Repeat these steps for each VNet that you want to connect.
Before you create a connection, be aware of the following:
-
A virtual network can only be connected to one virtual hub at a time.
-
In order to connect it to a virtual hub, the remote virtual network can't have a gateway (ExpressRoute or VPN) or RouteServer.
-
To connect a cross-tenant remote virtual network to the virtual hub, refer to Connect cross-tenant virtual networks to a Virtual WAN hub.
-
Make sure to check if you'd like to enable bypass next hop IP for workloads within this VNet for your connection.
-
Some configuration settings, such as Propagate static route, can only be configured in the Azure portal at this time. See the Azure portal version of this article for steps.
Important
If VPN gateways are present in the virtual hub, this operation as well as any other write operation on the connected VNet can cause disconnection to point-to-site clients as well as reconnection of site-to-site tunnels and BGP sessions.
- Verify that you have an Azure subscription. If you don't already have an Azure subscription, you can activate your MSDN subscriber benefits or sign up for a free account.
- The following steps assume that you have already created a site-to-site Virtual WAN VPN gateway.
[!INCLUDE PowerShell]
[!INCLUDE sign in]
-
Declare the variables for the existing resources, including the existing virtual network.
$resourceGroup = Get-AzResourceGroup -ResourceGroupName "TestRG" $virtualWan = Get-AzVirtualWan -ResourceGroupName "TestRG" -Name "TestVWAN1" $virtualHub = Get-AzVirtualHub -ResourceGroupName "TestRG" -Name "Hub1" $remoteVirtualNetwork = Get-AzVirtualNetwork -Name "VNet1" -ResourceGroupName "TestRG" -
Create a connection to peer the virtual network to the virtual hub.
New-AzVirtualHubVnetConnection -ResourceGroupName "TestRG" -VirtualHubName "Hub1" -Name "VNet1-connection" -RemoteVirtualNetwork $remoteVirtualNetwork
For more information about Virtual WAN, see the Virtual WAN FAQ.