Virtual Network Peering

Last updated: October 26, 2023

Virtual network (VNet) peering enables you to seamlessly connect Azure virtual networks. Connecting networks through VNet peering allows you to share resources across them. Traffic between peered virtual networks is private and stays within the Microsoft Azure backbone network. No internet, premium or disaster recovery path is needed for VNet peering.

Important

VNet peering is a relational private connection between two virtual networks that enables you to directly route traffic between them using private IP addresses. Virtual machines in either virtual network can communicate with each other as if they were within the same network. This communication is facilitated by the Azure backbone.

Benefits of VNet Peering

How VNet Peering Works

When you peer two virtual networks, you create a relationship between them. This relationship enables:

Peering Options

You can configure VNet peering in two ways:

  1. VNet peering within the same region: Connects VNets in the same Azure region.
  2. Global VNet peering: Connects VNets in different Azure regions.

Key Concepts

Address Spaces

For VNet peering to succeed, the address spaces of the peered VNets must not overlap. If they do overlap, the peering connection will fail.

Routing

When VNets are peered, VNet peering automatically propagates routes between them. You can also manually configure routes to control traffic flow.

Gateways

By default, a VNet that is peered with another VNet does not use its remote gateway. However, you can choose to use the remote gateway for transit routing.

Tip

Enabling 'Use remote gateways' in one VNet and 'Allow gateway transit' in the other VNet allows for hub-and-spoke network topology.

Creating a VNet Peering Connection

You can create VNet peering connections using the Azure portal, Azure CLI, Azure PowerShell, or ARM templates.

Using the Azure Portal

  1. Navigate to your virtual network in the Azure portal.
  2. In the left-hand menu, select Peerings under Settings.
  3. Click + Add.
  4. Fill in the required fields, including the name of the peering, the subscription, the target virtual network, and peering settings.
  5. Click Add to create the peering.

# Example Azure CLI command to create peering
az network vnet peering create \
  --name MyVNetPeering \
  --resource-group MyResourceGroup \
  --vnet-name MyVNet1 \
  --remote-vnet MyVNet2 \
  --allow-vnet-access
            

Considerations

Ensure that you configure the peering in both VNets for a successful connection. The connection is a bi-directional relationship.

Limitations and Considerations