Creating connections

To create connections, we need to take the following steps:

  1. First, get a reference to the two gateways:
$vnet1gw = Get-AzVirtualNetworkGateway -Name $GWName1 -ResourceGroupName $RG1
$vnet2gw = Get-AzVirtualNetworkGateway -Name $GWName2 -ResourceGroupName $RG2
  1. Next, we can create a connection. Make sure that the keys match:
New-AzVirtualNetworkGatewayConnection `
-Name $Connection01 `
-ResourceGroupName $RG1 `
-VirtualNetworkGateway1 $vnet1gw `
-VirtualNetworkGateway2 $vnet2gw `
-Location $Location1 `
-ConnectionType Vnet2Vnet `
-SharedKey 'AzurePacktGateway'

New-AzVirtualNetworkGatewayConnection `
-Name $Connection02 `
-ResourceGroupName $RG2 `
-VirtualNetworkGateway1 $vnet2gw `
-VirtualNetworkGateway2 $vnet1gw `
-Location $Location2 `
-ConnectionType Vnet2Vnet `
-SharedKey 'AzurePacktGateway'

In this demo, we configured a VNet-to-VNet connection. To do this, we created two VNets, both with a virtual network gateway. We also set up the connections between the gateways. In the next section, we are going to cover how you can verify the network connectivity for your VNet-to-VNet connection after creation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset