Cloud  /  Azure

Microsoft Azure 26 guides · updated 2026

Practical guides to Azure compute, networking, storage, and data services — built for engineers running production workloads on Microsoft's cloud.

Azure Virtual Network: Private Networking, Peering, and Hybrid Connectivity on Azure

An Azure Virtual Network (VNet) is a logically isolated network space in which your Azure resources communicate with each other, with the internet, and with your on-premises infrastructure. It is the fundamental networking building block in Azure — everything from a single VM to a Kubernetes cluster to a Private Endpoint lives inside a VNet.

Unlike traditional networking where physical topology matters, VNet boundaries are purely software-defined. You choose an IP address space (CIDR block), divide it into subnets, apply security rules, and define routes — all without touching physical switches or routers.


Real-World Scenario

A bank deploys a three-tier application: a public-facing web tier in one subnet, an application tier in a second subnet, and a database tier in a third subnet. NSG rules restrict the web subnet to receive traffic only on ports 443 and 80 from the internet. The application subnet only accepts traffic from the web subnet on port 8080. The database subnet only accepts traffic from the application subnet on port 1433. No traffic can flow between non-adjacent tiers. This network segmentation limits lateral movement if any tier is compromised.


VNet Structure

VNet: 10.0.0.0/16 (East US)
├── Subnet: web-subnet 10.0.1.0/24
│ NSG: Allow 443/80 from Internet
│ Allow 8080 to app-subnet
│ Resources: Load Balancer, Web VMs
├── Subnet: app-subnet 10.0.2.0/24
│ NSG: Allow 8080 from web-subnet only
│ Allow 1433 to db-subnet
│ Resources: Application VMs, AKS nodes
├── Subnet: db-subnet 10.0.3.0/24
│ NSG: Allow 1433 from app-subnet only
│ Resources: SQL VM, Private Endpoint
├── Subnet: GatewaySubnet 10.0.4.0/27
│ Reserved for VPN Gateway / ExpressRoute GW
└── Subnet: AzureFirewallSubnet 10.0.5.0/26
Reserved for Azure Firewall

Azure reserves five IP addresses in each subnet (first four and last). A /24 subnet has 251 usable addresses, not 256.


Network Security Groups (NSGs)

An NSG is a stateful firewall applied to a subnet or a NIC. Rules have a priority (lower number = higher priority, evaluated first), source/destination (IP, CIDR, or service tag), port, protocol, and allow/deny action.

NSG Rule Processing
--------------------
Traffic arrives
|
Evaluate rules in priority order (100, 200, 300...)
|
First matching rule applies (allow or deny)
|
If no match: default deny (inbound) or allow (outbound)
|
Response traffic automatically allowed (stateful)
Example NSG for web-subnet:
Priority | Name | Source | Port | Action
---------|--------------------|-----------------|----- |--------
100 | AllowHTTPS | Internet | 443 | Allow
110 | AllowHTTP | Internet | 80 | Allow
200 | AllowSSHFromBastion| AzureBastionSub | 22 | Allow
65000 | AllowVnetInBound | VirtualNetwork | Any | Allow (default)
65500 | DenyAllInBound | Any | Any | Deny (default)

NSGs use service tags (like Internet, VirtualNetwork, AzureLoadBalancer, Storage) to avoid listing individual IP ranges that change over time.


User-Defined Routes (UDRs)

Azure has implicit system routes (within VNet, to internet, to on-premises via gateway). UDRs override them. The most common use is forcing traffic through a network appliance:

Hub-and-Spoke with Azure Firewall (forced tunnelling)
------------------------------------------------------
Spoke VNet -> Subnet -> Route Table
0.0.0.0/0 -> Next hop: Azure Firewall (10.0.5.4)
10.1.0.0/16 -> Next hop: Azure Firewall (east spoke)
10.2.0.0/16 -> Next hop: Azure Firewall (west spoke)
All traffic between spokes and from spokes to internet
passes through the firewall for inspection and logging.
Without UDR, spoke-to-spoke traffic via VNet peering
bypasses the firewall.

UDRs are associated with subnets, not individual resources. Every resource in the subnet follows the same routing rules.


VNet Peering

VNet peering connects two VNets so their resources communicate over the Microsoft backbone network without encryption overhead and without traversing the public internet. Peering is non-transitive — if VNet A peers with B and B peers with C, traffic from A cannot reach C unless you add direct peering or route through a hub.

VNet Peering Topology
----------------------
Global Hub VNet (10.0.0.0/8)
Firewall, Bastion, DNS, VPN/ExpressRoute Gateway
| |
Peering A Peering B
| |
Spoke VNet A Spoke VNet B
(10.1.0.0/16) (10.2.0.0/16)
A->B traffic path: Spoke A -> Hub Firewall -> Spoke B
(transitivity via UDR + firewall, not peering)

Global VNet peering connects VNets across Azure regions with the same low-latency Microsoft backbone. Bandwidth is not metered within a region (free); global peering is charged per GB transferred.


Private Endpoints

A Private Endpoint gives a PaaS service (Blob Storage, SQL Database, Key Vault, etc.) a private IP address in your VNet. Traffic to the service stays on the Microsoft network and never traverses the public internet.

Private Endpoint Flow
----------------------
VM in subnet (10.0.2.5)
|
DNS resolution: mystorageacct.blob.core.windows.net
|
Private DNS Zone: mystorageacct.blob.core.windows.net -> 10.0.2.100
|
Traffic flows to Private Endpoint NIC (10.0.2.100) in your subnet
|
Microsoft backbone carries traffic to Azure Storage
(public endpoint of storage account can be disabled)

Private DNS zones are linked to the VNet so resolution returns the private IP. Without the DNS zone link, clients resolve the public IP even if a Private Endpoint exists.


VNet Integration for PaaS Services

Some PaaS services (App Service, Azure Functions on Premium plan, API Management) need outbound connectivity to private VNet resources. VNet Integration is different from a Private Endpoint:

VNet Integration vs. Private Endpoint
---------------------------------------
Private Endpoint: inbound into PaaS service from your VNet
VNet Integration: outbound FROM PaaS service INTO your VNet
Example:
App Service App
-> VNet Integration subnet (delegated)
-> Routes to 10.0.3.0/24 (db-subnet)
-> Reaches SQL Server on Private Endpoint (10.0.3.50)
Public internet -> Private Endpoint for App Service
-> Reaches App Service without public IP exposure (inbound)

Combine both for a fully private PaaS deployment: Private Endpoint for inbound (clients inside VNet reach the app), VNet Integration for outbound (app reaches private back-end services).


Key Interview Points


Best Practices