Creating virtual network peering using PowerShell

First off, you need to retrieve the virtual network information and store it in a variable using the following cmdlet:

$VNet1 = Get-AzureRmVirtualNetwork -ResourceGroupName PacktPub -Name PSVNet 
$VNet2 = Get-AzureRmVirtualNetwork -ResourceGroupName PacktPub -Name PSVNet2

Then, you will add the peer from vnet1 to vnet2 by running the following cmdlet:

Add-AzureRmVirtualNetworkPeering -Name PSVNetPeer -VirtualNetwork $vnet1 -RemoteVirtualNetworkId $vnet2.Id

After that, you will add the peer from vnet2 to vnet1 by running the following cmdlet:

Add-AzureRmVirtualNetworkPeering -Name PSVNetPeer -VirtualNetwork $vnet2 -RemoteVirtualNetworkId $vnet1.Id

Now, you are done and have the peer in a connected state.

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

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