O'Reilly logo

Hands-On Networking with Azure by Mohamed Waly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required