上QQ阅读APP看书,第一时间看更新
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.