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 --name CLIVNetPeering --resource-group PacktPub --vnet-name CLIVNet2 --remote-vnet-id $vnet1Id --allow-vnet-access
..................Content has been hidden....................

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