title | titleSuffix | description | author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|
Connect a VNet to a Virtual WAN hub - PowerShell |
Azure Virtual WAN |
Learn how to connect a VNet to a Virtual WAN hub using PowerShell. |
reasuquo |
virtual-wan |
how-to |
05/13/2022 |
reasuquo |
This article helps you connect your virtual network to your virtual hub using PowerShell. You can also use the Azure portal to complete this task. Repeat these steps for each VNet that you want to connect.
Note
- 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.
- 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.
- This tutorial creates a NAT rule on a VPN gateway that will be associated with a VPN site connection. The steps assume that you have an existing Virtual WAN VPN gateway connection to two branches with overlapping address spaces.
[!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 "myVirtualWAN" $virtualHub = Get-AzVirtualHub -ResourceGroupName "testRG" -Name "westushub" $remoteVirtualNetwork = Get-AzVirtualNetwork -Name "MyVirtualNetwork" -ResourceGroupName "testRG"
-
You can create a connection between a new virtual network or an already existing virtual network to peer the Virtual Network to the Virtual Hub. To create the connection:
New-AzVirtualHubVnetConnection -ResourceGroupName "testRG" -VirtualHubName "westushub" -Name "testvnetconnection" -RemoteVirtualNetwork $remoteVirtualNetwork
For more information about Virtual WAN, see the Virtual WAN FAQ.