Azure Virtual Network Peering

Connect VNets seamlessly to create an Azure networking backbone.

Understanding VNet Peering

Virtual network (VNet) peering enables you to connect Azure virtual networks privately through the Azure backbone network. Once peered, VNets can communicate with each other as if they were one network. Traffic between peered VNets is private and remains within the Microsoft Azure network.

Benefits of VNet Peering

Key Concepts

How VNet Peering Works

When you peer two VNets, you create a relationship that allows resources in each VNet to communicate directly. This is achieved through a private IP address connection. The following are key aspects:

Types of VNet Peering

VNet peering can be established in two ways:

  1. VNet-to-VNet Peering: Connects two VNets within the same Azure subscription.
  2. Global VNet Peering: Connects two VNets in different Azure regions. This is crucial for building resilient and distributed applications across geographical areas.

Peering Scenarios

VNet peering is commonly used in several scenarios:

Important Considerations:

  • No Transitive Peering: VNet peering is not transitive. If VNet A is peered with VNet B, and VNet B is peered with VNet C, VNet A cannot communicate with VNet C through VNet B. You must explicitly peer VNet A with VNet C.
  • Gateway Transit: By default, peered VNets cannot use the VPN or ExpressRoute gateways of the other VNet. You can enable gateway transit to allow one VNet to use the gateway of a peered VNet.
  • Service Endpoints and Private Endpoints: VNet peering supports service endpoints and private endpoints, allowing secure access to Azure services.

Peering Properties

When configuring VNet peering, you'll encounter several properties:

Property Description
Remote VNet The virtual network you are peering with.
Allow Virtual Network Access Enables resources in the local VNet to access resources in the remote VNet.
Allow Gateway Transit Allows traffic from the remote VNet to use the local VNet's gateway for access to on-premises networks or other VNets.
Use Remote Gateways Allows the local VNet to use the remote VNet's gateway for access to on-premises networks or other VNets.
Peering state Indicates the status of the peering connection (e.g., Initiated, Connected, Broken).

Configuring VNet Peering

You can configure VNet peering through the Azure portal, Azure CLI, or Azure PowerShell. The process typically involves:

  1. Navigating to your virtual network in the Azure portal.
  2. Selecting the "Peerings" option.
  3. Clicking "Add" to create a new peering connection.
  4. Specifying the details of the remote VNet and the peering properties.
  5. Repeating the process on the remote VNet to establish a bidirectional connection.

For example, to create a peering connection using Azure CLI:


az network vnet peering create \
  --resource-group MyResourceGroup \
  --vnet-name MyVNet \
  --name MyVNetToOtherVNet \
  --remote-vnet MyOtherVNet \
  --allow-vnet-access
            

Remember to configure peering in both directions: from your VNet to the remote VNet, and from the remote VNet back to your VNet.

Troubleshooting VNet Peering

Common issues include:

Utilize Azure Network Watcher's connection troubleshoot feature to diagnose connectivity issues.