Azure Virtual Network Deployment with Subnets and Peering
You will deploy an Azure Virtual Network with tiered subnets and peer it to a second VNet. By the end you will have a segmented cloud network foundation that VMs and services can join.
Learning Objectives
- Create a VNet with non-overlapping subnets.
- Peer two VNets for private connectivity.
- Verify routing between peered networks.
- Time: ~2 hours · Difficulty: Intermediate · Prereqs: the Azure CLI configured.
Architecture Overview
graph LR
subgraph VNet-A 10.0.0.0/16
Web[web 10.0.1.0/24]
App[app 10.0.2.0/24]
end
subgraph VNet-B 10.1.0.0/16
Data[data 10.1.1.0/24]
end
App <-->|peering| Data
Environment Setup
You will need: the Azure CLI authenticated with a default resource group set.
Before you begin: plan non-overlapping CIDR ranges; peered VNets cannot overlap.
Step-by-Step Execution
01
Create the VNet and subnets
az network vnet create -n vnet-a --address-prefixes 10.0.0.0/16 --subnet-name web --subnet-prefixes 10.0.1.0/2402
Add a second subnet
az network vnet subnet create --vnet-name vnet-a -n app --address-prefixes 10.0.2.0/2403
Peer two VNets
$ az network vnet peering create -n a-to-b --vnet-name vnet-a --remote-vnet vnet-b --allow-vnet-access
"peeringState": "Connected"
Progress So Far
graph LR
A[01 VNet + subnet] -->|done| B[02 Add subnet]
B -->|done| C[03 Peering]
style A fill:#1a4a1a,stroke:#00ff00,color:#fff
style B fill:#1a4a1a,stroke:#00ff00,color:#fff
style C fill:#1a4a1a,stroke:#00ff00,color:#fff
Testing & Validation
az network vnet peering show -n a-to-b --vnet-name vnet-a --query peeringState -o tsvYou should see Connected. With both directions peered, resources in app and data subnets can reach each other privately.
Troubleshooting
- Peering stuck at Initiated: create the peering in both directions; it requires a pair.
- Overlapping address space: peered VNets must use non-overlapping CIDR ranges.
- No connectivity despite peering: check NSGs and that
--allow-vnet-accessis set.
Extension Ideas
- Place a VM in a subnet with Azure VM Configuration.
- Control traffic with NSGs & Route Tables.
- Codify the whole network with IaC.
Key Results
- Deployed a VNet with two non-overlapping subnets.
- Connected two VNets via bidirectional peering.
- Confirmed the peering reached the Connected state.
- Built a segmented foundation for cloud workloads.