Skip to content

Networking

First PublishedLast UpdatedByAtif Alam

Every Azure resource that communicates over a network lives inside a VNet (Virtual Network). VNets are conceptually identical to AWS VPCs — your isolated network in the cloud.

┌───────────────────────────────────────────────────────┐
│ VNet: myapp-vnet 10.0.0.0/16 │
│ │
│ ┌────────────────────┐ ┌────────────────────┐ │
│ │ Public Subnet │ │ Public Subnet │ │
│ │ 10.0.1.0/24 │ │ 10.0.2.0/24 │ │
│ │ (AZ 1) │ │ (AZ 2) │ │
│ │ ┌──────┐ ┌──────┐ │ │ ┌──────┐ │ │
│ │ │ App GW│ │ NAT │ │ │ │ App GW│ │ │
│ │ └──────┘ └──────┘ │ │ └──────┘ │ │
│ └────────────────────┘ └────────────────────┘ │
│ │
│ ┌────────────────────┐ ┌────────────────────┐ │
│ │ Private Subnet │ │ Private Subnet │ │
│ │ 10.0.3.0/24 │ │ 10.0.4.0/24 │ │
│ │ (AZ 1) │ │ (AZ 2) │ │
│ │ ┌──────┐ ┌──────┐ │ │ ┌──────┐ ┌──────┐ │ │
│ │ │ VM │ │ DB │ │ │ │ VM │ │ DB │ │ │
│ │ └──────┘ └──────┘ │ │ └──────┘ └──────┘ │ │
│ └────────────────────┘ └────────────────────┘ │
└───────────────────────────────────────────────────────┘
Terminal window
# Create a VNet with two subnets
az network vnet create \
--resource-group myapp-rg \
--name myapp-vnet \
--address-prefix 10.0.0.0/16 \
--subnet-name frontend \
--subnet-prefix 10.0.1.0/24
az network vnet subnet create \
--resource-group myapp-rg \
--vnet-name myapp-vnet \
--name backend \
--address-prefix 10.0.3.0/24
AzureAWSPurpose
VNetVPCIsolated virtual network
SubnetSubnetIP range within the network
NSGSecurity Group + NACLFirewall rules (see stateful vs stateless below)
Azure Load BalancerNLBLayer 4 load balancing
Application GatewayALBLayer 7 load balancing (HTTP)
Azure DNSRoute 53DNS management
VNet PeeringVPC PeeringConnect two VNets
NAT GatewayNAT GatewayOutbound internet for private subnets
Azure FirewallAWS Network FirewallManaged firewall service
Private EndpointVPC EndpointPrivate access to Azure services

NSGs filter network traffic to and from Azure resources. They combine the functionality of AWS security groups and NACLs.

NSG rules are stateful for TCP and UDP in the usual sense: when you allow an inbound flow, Azure can associate return traffic so you do not need a separate rule for every ephemeral client port on the return path (similar to AWS security groups). You still think in terms of inbound vs outbound rules and priority (first match wins), which feels closer to NACL-style ordering than to “merge all SG rules.” For the cross-cloud vocabulary, see Stateful vs Stateless Firewalls on the AWS networking page and the TCP/IP primer. For TLS certificates in Azure, see Azure security (Key Vault) and TLS and Certificates for the AWS side of a hybrid mental model.

NSG rules have a priority (100–4096, lower = higher priority). Rules are evaluated in priority order — first match wins.

Inbound traffic ──► NSG rules (by priority) ──► Allow or Deny

Every NSG comes with default rules you can’t delete:

PriorityDirectionActionDescription
65000InboundAllowVNet to VNet traffic
65001InboundAllowAzure Load Balancer health probes
65500InboundDenyDeny all other inbound
65000OutboundAllowVNet to VNet traffic
65001OutboundAllowInternet outbound
65500OutboundDenyDeny all other outbound
Terminal window
# Create an NSG
az network nsg create --resource-group myapp-rg --name web-nsg
# Allow HTTP from anywhere
az network nsg rule create \
--resource-group myapp-rg \
--nsg-name web-nsg \
--name AllowHTTP \
--priority 100 \
--direction Inbound \
--access Allow \
--protocol Tcp \
--destination-port-ranges 80 443 \
--source-address-prefixes '*'
# Allow SSH from a specific IP
az network nsg rule create \
--resource-group myapp-rg \
--nsg-name web-nsg \
--name AllowSSH \
--priority 110 \
--direction Inbound \
--access Allow \
--protocol Tcp \
--destination-port-ranges 22 \
--source-address-prefixes 203.0.113.50/32
# Associate NSG with a subnet
az network vnet subnet update \
--resource-group myapp-rg \
--vnet-name myapp-vnet \
--name frontend \
--network-security-group web-nsg

ASGs let you group VMs logically and reference them in NSG rules (like AWS SG-to-SG references):

Terminal window
# Create ASGs
az network asg create --resource-group myapp-rg --name web-servers
az network asg create --resource-group myapp-rg --name db-servers
# Allow web-servers to access db-servers on port 5432
az network nsg rule create \
--resource-group myapp-rg \
--nsg-name backend-nsg \
--name AllowWebToDb \
--priority 100 \
--direction Inbound \
--access Allow \
--protocol Tcp \
--destination-port-ranges 5432 \
--source-asgs web-servers \
--destination-asgs db-servers

Distributes TCP/UDP traffic. Comparable to AWS NLB.

SKUFeaturesUse Case
BasicLimited, no AZ support, freeDev/test
StandardAZ-aware, zone-redundant, SLA, required for productionProduction
Terminal window
# Create a standard load balancer
az network lb create \
--resource-group myapp-rg \
--name my-lb \
--sku Standard \
--frontend-ip-name myFrontend \
--backend-pool-name myBackend \
--public-ip-address my-public-ip

HTTP/HTTPS load balancer with URL-based routing, SSL termination, and WAF. Comparable to AWS ALB.

Client ──► Application Gateway ──► /api/* ──► Backend Pool A (VMs)
──► /web/* ──► Backend Pool B (App Service)
──► /static/* ──► Backend Pool C (Storage)

Key features:

  • URL-based routing — Route by path or hostname.
  • SSL termination — Offload TLS at the gateway.
  • Web Application Firewall (WAF) — Built-in OWASP protection.
  • Autoscaling — Scale based on traffic.
  • Session affinity — Sticky sessions via cookies.

Global load balancer and CDN — comparable to AWS CloudFront + Global Accelerator:

  • Global HTTP/HTTPS routing with latency-based or priority-based routing.
  • Built-in WAF and DDoS protection.
  • SSL offloading at the edge.
  • Caching at edge locations worldwide.

Use Front Door for globally distributed applications; Application Gateway for regional applications.

Managed DNS service for hosting DNS zones:

Terminal window
# Create a DNS zone
az network dns zone create --resource-group myapp-rg --name example.com
# Add an A record
az network dns record-set a add-record \
--resource-group myapp-rg \
--zone-name example.com \
--record-set-name www \
--ipv4-address 20.50.100.150
# Add a CNAME
az network dns record-set cname set-record \
--resource-group myapp-rg \
--zone-name example.com \
--record-set-name api \
--cname api.azurewebsites.net

Azure Private DNS resolves names within a VNet (like AWS Route 53 private hosted zones).

Connect two VNets so resources can communicate directly using private IPs:

Terminal window
# Peer VNet-A to VNet-B
az network vnet peering create \
--resource-group rg-a \
--name a-to-b \
--vnet-name vnet-a \
--remote-vnet /subscriptions/.../resourceGroups/rg-b/providers/Microsoft.Network/virtualNetworks/vnet-b \
--allow-vnet-access
# Peer VNet-B to VNet-A (peering must be created in both directions)
az network vnet peering create \
--resource-group rg-b \
--name b-to-a \
--vnet-name vnet-b \
--remote-vnet /subscriptions/.../resourceGroups/rg-a/providers/Microsoft.Network/virtualNetworks/vnet-a \
--allow-vnet-access
  • Works across regions (global VNet peering) and across subscriptions.
  • Not transitive — A↔B and B↔C doesn’t give A↔C (use Azure Virtual WAN or hub-spoke with a firewall for that).

Access Azure PaaS services (Storage, SQL, Key Vault) over a private IP in your VNet — traffic never goes over the internet:

Terminal window
az network private-endpoint create \
--resource-group myapp-rg \
--name my-sql-pe \
--vnet-name myapp-vnet \
--subnet backend \
--private-connection-resource-id /subscriptions/.../Microsoft.Sql/servers/my-sql-server \
--group-ids sqlServer \
--connection-name my-sql-connection

The Azure SQL server now has a private IP (10.0.3.x) in your VNet. Disable public access on the SQL server to ensure all traffic goes through the private endpoint.

Provides outbound internet for private subnets (like AWS NAT Gateway):

Terminal window
# Create a NAT gateway
az network nat gateway create \
--resource-group myapp-rg \
--name my-nat-gw \
--public-ip-addresses my-nat-ip
# Associate with a subnet
az network vnet subnet update \
--resource-group myapp-rg \
--vnet-name myapp-vnet \
--name backend \
--nat-gateway my-nat-gw
  • A VNet is your isolated network. Plan CIDR ranges to avoid conflicts with other VNets and on-premises networks.
  • NSGs are firewall rules evaluated by priority (first match wins). Use ASGs for logical grouping.
  • Application Gateway for Layer 7 (HTTP routing, SSL, WAF); Azure Load Balancer for Layer 4 (TCP/UDP).
  • Azure Front Door for global applications with built-in CDN, WAF, and latency-based routing.
  • Use Private Endpoints to access PaaS services (SQL, Storage, Key Vault) over private IPs — no internet exposure.
  • VNet Peering connects two VNets directly. Not transitive — use hub-spoke topology with a firewall for complex networks.