VNet Peering

VNet peering connects two Azure Virtual Networks (VNets) together. This allows resources in each virtual network to communicate with each other. The traffic between virtual networks is routed through the Azure backbone network; it doesn't traverse the public internet. VNet peering provides lower latency and higher bandwidth than VPN gateways, making it an ideal solution for many inter-VNet connectivity scenarios.

Key Concepts of VNet Peering

When to Use VNet Peering

VNet peering is suitable for various scenarios:

VNet Peering Configuration Steps

To configure VNet peering, you'll need to perform the steps on both VNets involved.

Step 1: Navigate to the Virtual Network

In the Azure portal, go to the virtual network you want to configure peering for.

Step 2: Access the Peering Settings

In the virtual network's blade, select Peerings under the Settings section.

Step 3: Add a Peering Connection

Click on + Add to create a new peering connection.

Step 4: Configure Peering Details

You will be presented with a form to configure the peering settings:

Azure VNet Peering Configuration Screenshot
Azure Portal VNet Peering Configuration

Step 5: Repeat for the Remote VNet

You must repeat these steps on the other virtual network, configuring the peering connection back to the original VNet.

Considerations and Best Practices

Note: VNet peering is non-transitive. If VNet A is peered with VNet B, and VNet B is peered with VNet C, VNet A cannot communicate directly with VNet C through VNet B. You would need to explicitly peer VNet A with VNet C.

Example Scenario

Imagine you have two VNets:

To allow the web servers in VNet-App to connect to the database servers in VNet-DB, you would:

  1. Create a peering from VNet-App to VNet-DB.
  2. Create a peering from VNet-DB to VNet-App.

Ensure that Allow virtual network access is enabled on both peering connections. Resources in VNet-App can then communicate with resources in VNet-DB using their private IP addresses.

# Example CLI command to create a peering (simplified) # On VNet-App: az network vnet peering create \ --name VNetAppToVNetDB \ --resource-group myResourceGroup \ --vnet-name VNet-App \ --remote-vnet VNet-DB \ --allow-vnet-access # On VNet-DB: az network vnet peering create \ --name VNetDBToVNetApp \ --resource-group myResourceGroup \ --vnet-name VNet-DB \ --remote-vnet VNet-App \ --allow-vnet-access

Refer to the official Azure VNet Peering documentation for the most up-to-date information and advanced configurations.