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 Azure CLI

First off, you need to retrieve the virtual network ID using the following command for the peered VNet and store it in a variable to be used later:

$vnet1Id=$(az network vnet show --resource-group PacktPub --name CLIVNet --query id --out tsv)$vnet2Id=$(az network vnet show --resource-group PacktPub --name CLIVNet2 --query id --out tsv)

Then, you can create the peer from vnet1 to vnet2 by running the following command:

az network vnet peering create --name CLIVNetPeering --resource-group PacktPub --vnet-name CLIVNet --remote-vnet-id $vnet2Id --allow-vnet-access

Now, you can finalize that by creating the peer from vnet1 to vnet2 by running the following command:

az network vnet peering create ...

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