0
0
Azurecloud~10 mins

VNet peering for connectivity in Azure - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - VNet peering for connectivity
Create VNet A
Create VNet B
Request Peering from VNet A to VNet B
Request Peering from VNet B to VNet A
Peering Established
VNets can now communicate directly
This flow shows creating two virtual networks, requesting peering from each side, and establishing a connection allowing direct communication.
Execution Sample
Azure
az network vnet create --resource-group RG --location eastus --name VNetA --address-prefixes 10.0.0.0/16
az network vnet create --resource-group RG --location eastus --name VNetB --address-prefixes 10.1.0.0/16
VNETA_ID=$(az network vnet show --resource-group RG --name VNetA --query id --output tsv)
VNETB_ID=$(az network vnet show --resource-group RG --name VNetB --query id --output tsv)
az network vnet peering create --resource-group RG --vnet-name VNetA --name VNetAtoB --remote-vnet $VNETB_ID --allow-vnet-access
az network vnet peering create --resource-group RG --vnet-name VNetB --name VNetBtoA --remote-vnet $VNETA_ID --allow-vnet-access
This code creates two VNets and sets up peering from each to the other to enable connectivity.
Process Table
StepActionResource StateResult
1Create VNet A with address 10.0.0.0/16VNet A createdVNet A ready
2Create VNet B with address 10.1.0.0/16VNet B createdVNet B ready
3Create peering from VNet A to VNet BPeering request sentPeering A->B pending
4Create peering from VNet B to VNet APeering request sentPeering B->A pending
5Peering established both waysPeering activeVNets connected
6Test connectivity between VNetsPing from VNet A to VNet B succeedsConnectivity confirmed
💡 Peering established both ways, VNets can communicate directly
Status Tracker
ResourceInitial StateAfter Step 1After Step 2After Step 3After Step 4After Step 5
VNet ANot createdCreated with 10.0.0.0/16CreatedPeering A->B requestedPeering A->B requestedPeering active
VNet BNot createdNot createdCreated with 10.1.0.0/16CreatedPeering B->A requestedPeering active
Peering A->BNoneNoneNoneRequestedRequestedActive
Peering B->ANoneNoneNoneNoneRequestedActive
Key Moments - 3 Insights
Why do we need to create peering from both VNets?
Peering must be created from both sides (see steps 3 and 4 in execution_table) because Azure requires mutual approval to establish the connection.
Can VNets with overlapping address spaces be peered?
No, VNets must have non-overlapping IP address ranges to peer successfully, otherwise routing conflicts occur.
What happens if only one peering is created?
If only one peering exists (see step 3 or 4 alone), connectivity is not established because peering is not mutual.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step is the peering from VNet B to VNet A requested?
AStep 3
BStep 4
CStep 5
DStep 2
💡 Hint
Check the 'Action' column for peering requests in execution_table rows
According to variable_tracker, what is the state of Peering A->B after Step 3?
ARequested
BNone
CActive
DPending Approval
💡 Hint
Look at the Peering A->B row under After Step 3 in variable_tracker
If the address spaces of VNet A and VNet B overlapped, what would happen to the peering?
APeering would still be active
BPeering would be created but no connectivity
CPeering would fail due to IP conflict
DPeering would auto-correct address spaces
💡 Hint
Refer to key_moments about address space requirements
Concept Snapshot
VNet peering connects two Azure VNets for direct communication.
Create each VNet with unique IP ranges.
Set peering from both VNets to establish connection.
Peering allows resources to communicate privately.
Both sides must approve peering for it to be active.
Full Transcript
This lesson shows how to connect two Azure virtual networks using VNet peering. First, two VNets are created with distinct IP address spaces. Then, peering requests are created from each VNet to the other. Both peering requests must be active for the VNets to communicate. The execution table traces each step from creation to connectivity confirmation. Variable tracking shows the state changes of VNets and peering connections. Key moments clarify why peering must be mutual and why address spaces cannot overlap. The visual quiz tests understanding of peering steps and states. The concept snapshot summarizes the process simply.