az network vnet peering

Manage peering connections between Azure Virtual Networks.

To learn more about virtual network peering visit https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-manage-peering.

Commands

az network vnet peering create Create a virtual network peering connection.
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 virtual network peering connection.

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

Examples

Create a peering connection between two virtual networks.

az network vnet peering create -g MyResourceGroup -n MyVnet1ToMyVnet2 --vnet-name MyVnet1 \
                            --remote-vnet-id MyVnet2Id --allow-vnet-access

Required Parameters

--name -n

The name of the VNet peering.

--remote-vnet

Resource ID or name 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.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--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 [--ids]
[--name]
[--resource-group]
[--subscription]
[--vnet-name]

Examples

Delete a virtual network peering connection.

az network vnet peering delete -g MyResourceGroup -n MyVnet1ToMyVnet2 --vnet-name MyVnet1

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--vnet-name

The virtual network (VNet) name.

az network vnet peering list

List peerings.

az network vnet peering list [--ids]
[--resource-group]
[--subscription]
[--vnet-name]

Examples

List all peerings of a specified virtual network.

az network vnet peering list -g MyResourceGroup --vnet-name MyVnet1

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--vnet-name

The virtual network (VNet) name.

az network vnet peering show

Show details of a peering.

az network vnet peering show [--ids]
[--name]
[--resource-group]
[--subscription]
[--vnet-name]

Examples

Show all details of the specified virtual network peering.

az network vnet peering show -g MyResourceGroup -n MyVnet1ToMyVnet2 --vnet-name MyVnet1

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

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

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--vnet-name

The virtual network (VNet) name.

az network vnet peering update

Update a peering.

az network vnet peering update [--add]
[--force-string]
[--ids]
[--name]
[--remove]
[--resource-group]
[--set]
[--subscription]
[--vnet-name]

Examples

Change forwarded traffic configuration of a virtual network peering.

az network vnet peering update -g MyResourceGroup -n MyVnet1ToMyVnet2 --vnet-name MyVnet1 --set allowForwardedTraffic=true

Change virtual network access of a virtual network peering.

az network vnet peering update -g MyResourceGroup -n MyVnet1ToMyVnet2 --vnet-name MyVnet1 --set allowVirtualNetworkAccess=true

Change gateway transit property configuration of a virtual network peering.

az network vnet peering update -g MyResourceGroup -n MyVnet1ToMyVnet2 --vnet-name MyVnet1 --set allowGatewayTransit=true

Use remote gateways in virtual network peering.

az network vnet peering update -g MyResourceGroup -n MyVnet1ToMyVnet2 --vnet-name MyVnet1 --set useRemoteGateways=true

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--name -n

The name of the VNet peering.

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--vnet-name

The virtual network (VNet) name.