Fix Azure Virtual Network Peering Errors
When working with Azure Virtual Network, you may encounter a configuration error that prevents your deployment from working. This guide explains the most common mistake with peering and shows the exact fix.
A Common Mistake
Creating VNet peering in only one direction, causing connectivity to work in one direction but not the other.
The incorrect command:
az network vnet peering create --name vnet1-to-vnet2 --resource-group rg1 --vnet-name vnet1 --remote-vnet /subscriptions/sub2/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/vnet2 --allow-vnet-access
Error output:
Peering created from vnet1 to vnet2 only.
VM in vnet1 can ping VM in vnet2:
ping 10.100.2.4 - Reply from 10.100.2.4
But VM in vnet2 cannot ping VM in vnet1:
ping 10.100.1.4 - Request timed out
Bidirectional peering requires two peering connections.
The Correct Approach
The right way to configure peering in Azure Virtual Network:
az network vnet peering create --name vnet1-to-vnet2 --resource-group rg1 --vnet-name vnet1 --remote-vnet /subscriptions/sub2/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/vnet2 --allow-vnet-access
az network vnet peering create --name vnet2-to-vnet1 --resource-group rg2 --vnet-name vnet2 --remote-vnet /subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1 --allow-vnet-access
Successful result:
Both peerings created.
VM in vnet2 can ping VM in vnet1:
ping 10.100.1.4 - Reply from 10.100.1.4
Bidirectional connectivity established. Peering supports gateway transit and forwarded traffic.
How to Prevent This
Always create peering in both directions. Peering can be within same subscription, cross-subscription, or cross-tenant. Peering is not transitive -- hub-spoke requires peerings between hub and each spoke. Use az network vnet peering list to verify.
FAQ
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Secure your cloud with DodaTech.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro