> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# VNet Peering

> Explains Azure VNet peering, features, configuration flags, regional and global modes, hub-spoke topologies with NVAs and gateway transit, addressing, routing, and troubleshooting.

Azure Virtual Network (VNet) peering connects separate VNets so resources (for example, virtual machines) communicate privately using their private IP addresses. Peering uses the Microsoft backbone network, providing low-latency, high-bandwidth connectivity without traversing the public internet. This enables secure, fast communication that preserves the native network experience.

What you'll learn in this article:

* When to use VNet peering (regional vs. global)
* Key features and configuration flags
* How peering fits into common topologies such as hub-spoke with NVAs and gateway transit
* Addressing and routing considerations

## Types of VNet peering

VNet peering supports two modes:

| Peering type          | Scope                        | Use case                                                                                                                |
| --------------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| Regional VNet peering | Within the same Azure region | Low-latency communication between VNets in a single region (e.g., for microservice separation or environment isolation) |
| Global VNet peering   | Across Azure regions         | Connect VNets across regions for geo-redundancy, multi-region services, or cross-region migrations                      |

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/JJJT303TRGQwcVP2/images/AZ-700-Designing-and-Implementing-Microsoft-Azure-Networking-Solutions/Enable-Cross-VNet-Connectivity/VNet-Peering/vnet-peering-global-regional-diagram.jpg?fit=max&auto=format&n=JJJT303TRGQwcVP2&q=85&s=b450b923c26ed0dc5e2d96244745b0ed" alt="The image depicts types of VNet peering, showing Global VNet Peering between VNet1 in Region 1 and VNet2 in Region 2, and Regional VNet Peering between VNet2 and VNet3 within Region 2." width="1920" height="1080" data-path="images/AZ-700-Designing-and-Implementing-Microsoft-Azure-Networking-Solutions/Enable-Cross-VNet-Connectivity/VNet-Peering/vnet-peering-global-regional-diagram.jpg" />
</Frame>

This flexibility lets you design either regional or global topologies depending on requirements such as latency, data residency, or redundancy.

## Key features

1. Data path

* Traffic between peered VNets flows directly over the Microsoft backbone network; it does not transit the public internet. This improves both performance and security.

2. Cross-subscription and cross-tenant support

* You can peer VNets across subscriptions and Azure Active Directory tenants (with the correct authorization). This is useful for multi-account organizations or when consolidating services across business units.

3. Peering controls and configuration flags

* Each peering has several important configuration options you should plan for when designing your network.

| Flag                        | Default | Description                                                                      | Typical use                                                |
| --------------------------- | ------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `AllowVirtualNetworkAccess` | true    | Enables traffic between the two VNets.                                           | Default connectivity between peered VNets.                 |
| `AllowForwardedTraffic`     | false   | Allows forwarded traffic from an NVA in the peered VNet to reach the local VNet. | Required for hub NVAs forwarding transit traffic.          |
| `AllowGatewayTransit`       | false   | Allows a peered VNet to advertise its gateway to other VNets.                    | Enable on the hub VNet to allow spokes to use its gateway. |
| `UseRemoteGateways`         | false   | Lets a VNet use the gateway of a peered VNet.                                    | Enable on spokes when centralizing gateway in the hub.     |

4. Non-transitive connectivity

* VNet peering is non-transitive. If VNet A is peered to VNet B, and VNet B is peered to VNet C, A does not have automatic connectivity to C. You must peer A↔C directly or forward traffic explicitly using an NVA and appropriate routing.

<Callout icon="warning" color="#FF6B6B">
  Peering is non-transitive by design. If you expect hub-to-spoke transit, configure user-defined routes and allow forwarded traffic where necessary. Assuming transitive connectivity without explicit configuration can break traffic flows.
</Callout>

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/JJJT303TRGQwcVP2/images/AZ-700-Designing-and-Implementing-Microsoft-Azure-Networking-Solutions/Enable-Cross-VNet-Connectivity/VNet-Peering/vnet-peering-diagram-global-regional.jpg?fit=max&auto=format&n=JJJT303TRGQwcVP2&q=85&s=2363b43bc88fc0392c151c3a8bded7a5" alt="The image illustrates VNet Peering features, showing a diagram with global and regional peering connections between virtual networks (VNet1, VNet2, VNet3) across two regions. It highlights features such as data path, multi-tenant support, and non-transitivity." width="1920" height="1080" data-path="images/AZ-700-Designing-and-Implementing-Microsoft-Azure-Networking-Solutions/Enable-Cross-VNet-Connectivity/VNet-Peering/vnet-peering-diagram-global-regional.jpg" />
</Frame>

## Example: Create VNet peering (Azure CLI)

Here is a concise example that creates peering between two VNets using the Azure CLI. Adjust names, resource groups, and locations to your environment.

```bash theme={null}
# Create peering from VNetA to VNetB
az network vnet peering create \
  --name VNetA-to-VNetB \
  --resource-group rg-a \
  --vnet-name VNetA \
  --remote-vnet /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/rg-b/providers/Microsoft.Network/virtualNetworks/VNetB \
  --allow-vnet-access true

# Create peering from VNetB to VNetA (reciprocal)
az network vnet peering create \
  --name VNetB-to-VNetA \
  --resource-group rg-b \
  --vnet-name VNetB \
  --remote-vnet /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/rg-a/providers/Microsoft.Network/virtualNetworks/VNetA \
  --allow-vnet-access true
```

Note: For `AllowGatewayTransit` and `UseRemoteGateways`, you must set these appropriately on the hub and spoke peerings and deploy a gateway in the hub's `GatewaySubnet`.

## Hub-spoke architecture, NVAs, and gateway transit

A common design pattern is hub-spoke, where the hub VNet hosts shared services (for example, an NVA, firewall, VPN gateway, or ExpressRoute). Spokes peer with the hub to consume those shared services.

NVAs and forwarding

* Because peering is non-transitive, to route traffic from Spoke A to Spoke B via an NVA in the hub:
  * Configure user-defined routes (UDRs) in the spokes to direct the relevant traffic to the hub NVA.
  * Enable `AllowForwardedTraffic` on the peering(s) if the NVA will forward traffic across peered VNets.
  * Ensure the NVA’s routing and Network Security Groups (NSGs) allow and forward the traffic to the intended destination.

Gateway transit

* To centralize an on-premises VPN or ExpressRoute gateway in the hub (saving cost and simplifying management):
  * On the hub peering, enable `AllowGatewayTransit`.
  * On the spoke peering(s), enable `UseRemoteGateways`.
  * The hub must have a VPN or ExpressRoute gateway deployed in its `GatewaySubnet`.
* Centralizing gateways requires careful capacity, routing, and security planning; monitor throughput and failover behavior.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/JJJT303TRGQwcVP2/images/AZ-700-Designing-and-Implementing-Microsoft-Azure-Networking-Solutions/Enable-Cross-VNet-Connectivity/VNet-Peering/vnet-peering-diagram-gateway-subnets.jpg?fit=max&auto=format&n=JJJT303TRGQwcVP2&q=85&s=546052dc5dd747348c2d3559f33c976d" alt="The image is a diagram illustrating the implementation of VNet peering between three virtual networks (VNet A, HUB VNet, and VNet B) with labels indicating gateway transit, remote gateway usage, and peering connections. It includes elements like subnets, NVA, VPN gateway, and UDR." width="1920" height="1080" data-path="images/AZ-700-Designing-and-Implementing-Microsoft-Azure-Networking-Solutions/Enable-Cross-VNet-Connectivity/VNet-Peering/vnet-peering-diagram-gateway-subnets.jpg" />
</Frame>

## Address space requirements

* Peered VNets must have non-overlapping IP address ranges. If address spaces overlap, the peering cannot be created.
* Plan address spaces during design to avoid collisions and to accommodate future growth and cross-region expansion.

<Callout icon="lightbulb" color="#1CB2FE">
  Plan IP addressing and peering settings (`AllowForwardedTraffic`, `AllowGatewayTransit`, `UseRemoteGateways`) before implementation. Early planning prevents routing surprises in hub-spoke and NVA scenarios.
</Callout>

## Troubleshooting checklist

* Confirm address spaces do not overlap.
* Verify peering status is "Connected" in both VNets.
* Check `AllowVirtualNetworkAccess`, `AllowForwardedTraffic`, and gateway settings on both sides.
* Validate UDRs and NSGs to ensure traffic is routed and permitted as expected.
* For cross-tenant peering, ensure the required role assignments and authorizations are in place.

## Summary and next steps

VNet peering provides private, high-performance connectivity across VNets using the Microsoft backbone. It supports cross-subscription and cross-tenant peering and enables hub-spoke topologies with NVAs and centralized gateways when properly configured. Remember:

* Peering is non-transitive—explicit peering or NVAs + routing are required for multi-hop connectivity.
* VNets must have non-overlapping address spaces.
* Plan peering flags and routing before deployment.

Next steps:

* Follow the Azure portal walkthrough or the Azure CLI examples to create peering in your subscription.
* Review related concepts: Virtual Network, Network Security Groups, User-Defined Routes (UDRs), and Azure VPN/ExpressRoute gateways.

Links and references

* [Azure Virtual Network peering overview](https://learn.microsoft.com/azure/virtual-network/virtual-network-peering)
* [Designing a hub-spoke topology in Azure](https://learn.microsoft.com/azure/architecture/reference-architectures/hybrid-networking/hub-spoke)
* [Azure CLI: az network vnet peering](https://learn.microsoft.com/cli/azure/network/vnet/peering)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/az-700-designing-and-implementing-microsoft-azure-networking-solutions/module/788bfe49-db39-491a-82d2-847c85bbcceb/lesson/516e8e6d-67c6-49e8-9b91-ada86b2f2a3d" />
</CardGroup>
