Lab 2: Hub-and-Spoke Network with Peering, Routing, Private DNS and Storage Private Endpoint
Goal
text
vnet-hub 10.0.0.0/16 <== peering ==> vnet-spoke1 10.1.0.0/16 (VM: vm-spoke1)
<== peering ==> vnet-spoke2 10.2.0.0/16 (VM: vm-spoke2)
Storage account with PRIVATE ENDPOINT in spoke1, private DNS zone privatelink.blob.core.windows.net linked to all VNets
Step 1: Three VNets
bash
az group create -n rg-lab2 -l centralindia
for n in hub:10.0 spoke1:10.1 spoke2:10.2; do
name=${n%%:*}; pre=${n##*:}
az network vnet create -g rg-lab2 -n vnet-$name --address-prefixes $pre.0.0/16 --subnet-name default --subnet-prefixes $pre.1.0/24
done
Step 2: Peering
bash
for s in spoke1 spoke2; do
az network vnet peering create -g rg-lab2 -n hub-to-$s --vnet-name vnet-hub --remote-vnet vnet-$s --allow-vnet-access --allow-forwarded-traffic
az network vnet peering create -g rg-lab2 -n $s-to-hub --vnet-name vnet-$s --remote-vnet vnet-hub --allow-vnet-access --allow-forwarded-traffic
done
az network vnet peering list -g rg-lab2 --vnet-name vnet-hub -o table
Step 3: Test VMs and Connectivity
bash
for s in spoke1 spoke2; do
az vm create -g rg-lab2 -n vm-$s --image Ubuntu2204 --size Standard_B1s --vnet-name vnet-$s --subnet default --public-ip-address "" --admin-username azureuser --generate-ssh-keys --no-wait
done
az vm run-command invoke -g rg-lab2 -n vm-spoke1 --command-id RunShellScript --scripts "ping -c 3 10.2.1.4 || echo no route"
Expected result Spoke1 to spoke2 fails. Peering is not transitive. Spokes only reach the hub.
Step 4: Make Spokes Talk Through the Hub
In a real design you place a firewall or NVA in the hub and add UDRs to each spoke so spoke-to-spoke traffic goes through it.
bash
az network route-table create -g rg-lab2 -n rt-spoke1
az network route-table route create -g rg-lab2 --route-table-name rt-spoke1 -n to-spoke2 --address-prefix 10.2.0.0/16 \
--next-hop-type VirtualAppliance --next-hop-ip-address 10.0.1.4
az network vnet subnet update -g rg-lab2 --vnet-name vnet-spoke1 -n default --route-table rt-spoke1
az network nic show-effective-route-table -g rg-lab2 -n vm-spoke1VMNic -o table
Use Network Watcher > Next hop from vm-spoke1 to 10.2.1.4 and confirm the next hop is the virtual appliance.
Step 5: Storage With a Private Endpoint
bash
az storage account create -g rg-lab2 -n stlab2482 --sku Standard_LRS --allow-blob-public-access false
SA=$(az storage account show -g rg-lab2 -n stlab2482 --query id -o tsv)
az network vnet subnet update -g rg-lab2 --vnet-name vnet-spoke1 -n default --disable-private-endpoint-network-policies true
az network private-endpoint create -g rg-lab2 -n pe-blob --vnet-name vnet-spoke1 --subnet default --private-connection-resource-id $SA --group-id blob --connection-name c1
az network private-dns zone create -g rg-lab2 -n privatelink.blob.core.windows.net
for v in hub spoke1 spoke2; do
az network private-dns link vnet create -g rg-lab2 -z privatelink.blob.core.windows.net -n link-$v -v vnet-$v -e false
done
az network private-endpoint dns-zone-group create -g rg-lab2 --endpoint-name pe-blob -n zg --private-dns-zone privatelink.blob.core.windows.net --zone-name blob
az storage account update -g rg-lab2 -n stlab2482 --public-network-access Disabled
Step 6: Verify
bash
az vm run-command invoke -g rg-lab2 -n vm-spoke1 --command-id RunShellScript --scripts "nslookup stlab2482.blob.core.windows.net"
- The name should resolve to a private
10.1.x.xaddress from every linked VNet - From outside Azure the account is not reachable because public access is disabled
- If the name resolves to a public IP, the DNS zone link or record is missing
Clean Up
bash
az group delete -n rg-lab2 --yes --no-wait
What You Practiced
- Hub and spoke design, peering both ways, non-transitivity
- Route tables and effective routes, Network Watcher next hop
- Private endpoints and private DNS, disabling public access
Conclusion
You connected VNets with peering, proved peering is not transitive, controlled routes with a UDR, and secured storage with a private endpoint and private DNS.
Quick Summary: goal; VNets; peering; test; routing; private endpoint; verify; cleanup.

