az network vnet peering

Manage peering connections between Azure Virtual Networks.

Commands

az network vnet peering create Create a peering.
az network vnet peering delete Delete a peering.
az network vnet peering list List peerings.
az network vnet peering show Show details of a peering.
az network vnet peering update Update a peering.

az network vnet peering create

Create a peering.

az network vnet peering create --name
--remote-vnet-id
--resource-group
--vnet-name
[--allow-forwarded-traffic]
[--allow-gateway-transit]
[--allow-vnet-access]
[--use-remote-gateways]

Examples

Create a virtual network peering between virtual networks in the same region

az network vnet create --name myVnet1 --resource-group myResourceGroup --location eastus --address-prefix 10.0.0.0/16 nn az network vnet create --name myVnet2 --resource-group myResourceGroup --location eastus --address-prefix 10.1.0.0/16 nn vnet1Id=$(az network vnet show --resource-group myResourceGroup--name myVnet1 --query id --out tsv) nn vnet2Id=$(az network vnet show --resource-group myResourceGroup --name myVnet2 --query id --out tsv) nn az network vnet peering create --name myVnet1ToMyVnet2 --resource-group myResourceGroup --vnet-name myVnet1 --remote-vnet-id $vnet2Id --allow-vnet-access nn az network vnet peering create --name myVnet2ToMyVnet1 --resource-group myResourceGroup --vnet-name myVnet2 --remote-vnet-id $vnet1Id --allow-vnet-access

Create a virtual network peering between virtual networks in different regions

az network vnet create --name myVnet1 --resource-group myResourceGroup --location westcentralus --address-prefix 10.0.0.0/16 nn az network vnet create --name myVnet2 --resource-group myResourceGroup --location canadacentral --address-prefix 10.2.0.0/16 nn vnet1Id=$(az network vnet show --resource-group myResourceGroup--name myVnet1 --query id --out tsv) nn vnet2Id=$(az network vnet show --resource-group myResourceGroup --name myVnet2 --query id --out tsv) nn az network vnet peering create --name myVnet1ToMyVnet2 --resource-group myResourceGroup --vnet-name myVnet1 --remote-vnet-id $vnet2Id --allow-vnet-access nn az network vnet peering create --name myVnet2ToMyVnet1 --resource-group myResourceGroup --vnet-name myVnet2 --remote-vnet-id $vnet1Id --allow-vnet-access

Required Parameters

--name -n
The name of the VNet peering.
--remote-vnet-id
ID of the remote VNet.
--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.
--vnet-name
The virtual network (VNet) name.

Optional Parameters

--allow-forwarded-traffic
Allows forwarded traffic from the VMs in the remote VNet.
--allow-gateway-transit
Allows gateway link to be used in the remote VNet.
--allow-vnet-access
Allows VMs in the remote VNet to access all VMs in the local VNet.
--use-remote-gateways
Allows VNet to use the remote VNet's gateway. Remote VNet gateway must have --allow-gateway-transit enabled for remote peering. Only 1 peering can have this flag enabled. Cannot be set if the VNet already has a gateway.

az network vnet peering delete

Delete a peering.

az network vnet peering delete --name
--resource-group
--vnet-name

Examples

Delete a virtual network peering

az network vnet peering delete --name myVnet1toMyVnet2 --resource-group myResourceGroup --vnet-name myVnet1

Required Parameters

--name -n
The name of the VNet peering.
--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.
--vnet-name
The virtual network (VNet) name.

az network vnet peering list

List peerings.

az network vnet peering list --resource-group
--vnet-name

Examples

List all peerings of a specified virtual network

az network vnet peering list --resource-group myResourceGroup --vnet-name myVnet1

Required Parameters

--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.
--vnet-name
The virtual network (VNet) name.

az network vnet peering show

Show details of a peering.

az network vnet peering show --name
--resource-group
--vnet-name

Examples

Show all details of the specified virtual network peering.

az network vnet peering show --name myVnet1toMyVnet2 --resource-group myResourceGroup --vnet-name myVnet1

Required Parameters

--name -n
The name of the VNet peering.
--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.
--vnet-name
The virtual network (VNet) name.

az network vnet peering update

Update a peering.

az network vnet peering update --name
--resource-group
--vnet-name
[--add]
[--remove]
[--set]

Examples

Change forwarded traffic configuration of a virtual network peering

az network vnet peering update ---name myVnet1toMyVnet2 --resource-group myResourceGroup --vnet-name myVnet1 --set allowForwardedTraffic==true

Change virtual network access of a virtual network peering

az network vnet peering update ---name myVnet1toMyVnet2 --resource-group myResourceGroup --vnet-name myVnet1 --set allowVirtualNetworkAccess==true

Change gateway transit property configuration of a virtual network peering

az network vnet peering update ---name myVnet1toMyVnet2 --resource-group myResourceGroup --vnet-name myVnet1 --set allowGatewayTransit==true

Use remote gateways in virtual network peering

az network vnet peering update ---name myVnet1toMyVnet2 --resource-group myResourceGroup --vnet-name myVnet1 --set useRemoteGateways==true

Required Parameters

--name -n
The name of the VNet peering.
--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.
--vnet-name
The virtual network (VNet) name.

Optional Parameters

--add
Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty .
--remove
Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.
--set
Update an object by specifying a property path and value to set. Example: --set property1.property2=.