Documentation Index
Fetch the complete documentation index at: https://resources.devweekends.com/llms.txt
Use this file to discover all available pages before exploring further.
Networking Fundamentals
This chapter will teach you everything about networking in Azure, starting from absolute basics. We’ll explain what networking actually is, why it matters, and how to build secure, scalable network architectures from scratch.What You’ll Learn
By the end of this chapter, you’ll understand:- What networking is and why applications need it (from scratch)
- IP addresses, subnets, and CIDR notation explained simply
- Virtual Networks (VNets) and how they work
- Network Security Groups (NSGs) and firewall rules
- Private vs Public networking (when to use each)
- How to design secure network architectures
- Common networking patterns and best practices
What is Networking? (Start Here if You’re New)
Let’s start with the absolute basics.The Simple Explanation
Networking = How computers talk to each other When you:- Visit a website → Your computer talks to a web server
- Send an email → Your email app talks to an email server
- Watch a video → Your device talks to a video streaming server
Real-World Analogy: Postal System
Think of networking like the postal system: Postal System:- Every house has an address (123 Main Street)
- Mail is delivered based on address
- Post office routes mail to correct destination
- Can send letters anywhere in the world
- Every computer has an IP address (192.168.1.10)
- Data is delivered based on IP address
- Routers route data to correct destination
- Can send data anywhere on the internet
Why Do Applications Need Networking?
Without Networking:What is an IP Address?
IP Address = The unique address of a computer on a network Just like your home address (123 Main Street, New York, NY 10001), every computer needs an address so others can find it. Two Types of IP Addresses: IPv4 (What we’ll use):Public vs Private IP Addresses
This is CRITICAL to understand: Public IP Addresses:What is a Virtual Network (VNet)?
VNet = Your private network in Azure’s datacenter Real-World Analogy: Office BuildingUnderstanding CIDR Notation (The /16, /24 Numbers)
CIDR (Classless Inter-Domain Routing) is just a way to specify how many IP addresses you have. The Simple Rule:| CIDR | Addresses | Typical Use |
|---|---|---|
| /8 | 16.7 million | Entire cloud provider |
| /16 | 65,536 | VNet address space |
| /20 | 4,096 | Large subnet (Kubernetes) |
| /24 | 256 | Standard subnet |
| /26 | 64 | Small subnet |
| /28 | 16 | Tiny subnet (gateways) |
| /32 | 1 | Single IP address |
Under the Hood: The “Magic” of SDN
How does Azure move billions of packets per second between virtual machines without a physical router for every customer? This is the power of Software Defined Networking (SDN). Real-World Analogy: The Invisible Mail Room Think of Azure SDN like a massive corporate mail room that you never see. When you send a letter (packet) from your desk (VM), you just write the recipient’s name. The mail room figures out which building, floor, and desk to deliver it to — you never deal with the physical routing. If the recipient moves desks, the mail room updates its records automatically. That is SDN: the physical network hardware is decoupled from the routing logic, which is managed entirely in software.The Virtual Filter (Host Agent)
When your VM sends a packet, it doesn’t just hit a wire. It hits the Azure Virtual Filtering Platform (VFP), which is an extension of the Hyper-V switch in the physical host.- Stateful Inspection: The Host Agent checks if this packet matches your NSG rules. This happens at wire speed — your NSG rules are compiled into efficient lookup tables on the physical host, not evaluated one-by-one like a script.
- Encapsulation: If allowed, the packet is wrapped (encapsulated) in a VXLAN/NVGRE tunnel. This is how Azure keeps your traffic isolated from other tenants on the same physical network — your packet rides inside another packet, like a letter inside an envelope.
- The Global Backbone: The packet travels over the physical datacenter network. Azure’s backbone network spans over 250,000 km of fiber optic cable connecting all regions.
- Decapsulation: The destination host unwraps the packet and delivers it to the target VM.
The WireServer (168.63.129.16)
You will see this IP address in your network logs frequently. It is the Azure WireServer. It is a “magic” IP that exists in every subnet but doesn’t live on any specific machine. It provides:- DNS: Resolving internal Azure names.
- DHCP: Assigning IP addresses to your VMs.
- Health Probes: Checking if your VMs are alive for the Load Balancer.
[!IMPORTANT]
Pro Tip: Don’t Block the Magic
If you create a custom NSG that blocks 168.63.129.16, your VM’s health probes will fail, it will lose its IP address, and it will effectively “disappear” from the network. Always allow this IP in your custom configurations.
Network Security: How to Control Traffic
Now that you understand IP addresses and VNets, let’s learn how to SECURE them.What is a Firewall?
Firewall = A security guard that controls what traffic is allowed Real-World Analogy: Building SecurityNetwork Security Groups (NSGs)
NSG = Azure’s firewall for VNets and VMs How NSGs Work:Real-World Example: 3-Tier Web Application
Let’s design a complete network architecture:1. IP Addressing & Subnetting Strategy
Correctly planning your IP address space is the single most critical step. You cannot easily change a VNet’s address space after peering it.CIDR Deep Dive
Azure uses Classless Inter-Domain Routing (CIDR) notation.
[!TIP]
Jargon Alert: CIDR Block
A way to state “IP Address + Network Size”.
10.0.0.0/16 means “Start at 10.0.0.0, and the first 16 bits are fixed.” The remaining 16 bits are for your devices.
Subnet Calculation Cheat Sheet
| CIDR | Total IPs | Usable IPs (Azure) | Use Case |
|---|---|---|---|
/16 | 65,536 | 65,531 | VNet Address Space (Standard enterprise size) |
/20 | 4,096 | 4,091 | Large Subnet (AKS Clusters) |
/24 | 256 | 251 | Standard Subnet (Web tier, App tier) |
/26 | 64 | 59 | Gateway Subnet (VPN/ExpressRoute) |
/27 | 32 | 27 | Azure Bastion (Required size) |
/29 | 8 | 3 | Tiny Subnet (Azure Firewall management) |
[!WARNING] Gotcha: Azure’s 5 Reserved IPs In every subnet, Azure reserves 5 IP addresses:Implication: A
x.x.x.0: Network addressx.x.x.1: Default gatewayx.x.x.2: Azure DNS mappingx.x.x.3: Azure DNS mappingx.x.x.255: Broadcast address (Azure doesn’t support broadcast)/29subnet only has 3 usable IPs!
2. Network Security Groups (NSG) vs Application Security Groups (ASG)
Network Security Groups (NSG)
The firewall for your subnet or network interface (NIC). It contains a list of Allow/Deny rules. Key Rules:- Priority: Lower number = Higher priority (100 overrides 200).
- 5-Tuple: Source IP, Source Port, Dest IP, Dest Port, Protocol.
- Stateful: If you allow traffic IN, the response OUT is automatically allowed.
Application Security Groups (ASG)
ASGs allow you to group VMs by their function rather than their IP address. The Problem: You have 10 web servers. You want to allow Port 80 to all of them. Traditional Way: Create an NSG rule for each IP, or put them all in one tidy subnet. ASG Way: Tag the NICs with “WebASG”. Create ONE NSG rule: “Allow Internet to WebASG”.[!NOTE] Deep Dive: When to use ASGs? Use ASGs when you have multiple fast-changing workloads in a single subnet and need granular micro-segmentation. If you just have tiered subnets (Web, App, DB), standard subnet-level NSGs are usually cleaner.
3. Secure Access: Service Endpoints vs Private Link
This is a favorite interview topic. Both secure access to PaaS (SQL, Storage), but differently.| Feature | Service Endpoints | Private Link (Private Endpoint) |
|---|---|---|
| Traffic Path | Optimized route over Azure backbone | Private IP inside your VNet |
| PaaS IP | Public IP | Private IP (e.g., 10.0.1.5) |
| On-Prem Access | No (unless forced tunneling) | Yes (via VPN/ExpressRoute) |
| Data Exfiltration | Harder to block | protected (maps to specific instance) |
| Cost | Free | $/hour + Data processing charge |
Service Endpoints
“Leaves” your VNet to talk to the Public PaaS resource, but Azure recognizes the traffic is coming from your subnet. Think of it as a VIP fast lane on the highway — you still use the public road (Azure backbone), but the destination (Storage, SQL) sees your VIP badge (subnet identity) and lets you in through a private gate. Cost Tip: Service Endpoints are completely free. If your workloads are Azure-only (no on-premises access needed) and you don’t need data exfiltration protection, start with Service Endpoints. You can always upgrade to Private Link later — but Private Link costs approximately 0.01/GB of data processed.Packet Path Analysis: Service Endpoints vs. Private Link
To truly master this, you must understand where the packet goes. Service Endpoint Packet Path:- VM (10.0.1.5) → Next Hop: “VirtualNetwork”
- Traffic hits the Azure Backbone.
- Source IP is changed (Internal SNAT) to a Microsoft-owned Public IP.
- Destination is the Regional Public IP of the Storage/SQL service.
- Security: The PaaS resource must have its firewall configured to “Allow access from Virtual Network X”.
- VM (10.0.1.5) → Next Hop: 10.0.1.10 (The Private Endpoint IP)
- Traffic never leaves your VNet.
- Destination is a Local Private IP sitting inside your subnet.
- Security: The PaaS resource’s public network access can be set to DISABLED. It is literally invisible to the internet.
[!IMPORTANT] Pro Tip: DNS is the Hard Part When you use Private Link, your app still wants to talk tomystorage.blob.core.windows.net. You need a Private DNS Zone linked to your VNet so thatmystorage.blob.core.windows.netresolves to10.0.1.10instead of the public IP.
4. Subnet Delegation
Some Azure services require a “Delegated Subnet”. This means they take full control of that subnet—you cannot put anything else in it. Services requiring delegation:- Azure NetApp Files
- Azure SQL Managed Instance
- App Service VNet Integration (Standard)
- Azure Databricks
[!WARNING] Gotcha: Subnet Delegation sizing Once delegated, resizing is painful. Azure SQL Managed Instance requires a minimum/27, but Microsoft recommends/26or/25for scaling. If you start too small, you have to rebuild the cluster.
Hub-and-Spoke Topology
This is the standard architecture for enterprise Azure environments. Instead of peering every VNet to every other VNet (which creates a “Spaghetti Network”), you use a Central Hub. Why professionals use Hub-and-Spoke:- Shared Services: Place your Firewall, VPN Gateway, and Domain Controllers in the Hub to save money and simplify management. Without this pattern, you would need a separate Firewall in every VNet — at $900+/month each, that adds up fast.
- Security: All traffic between Spokes (Spoke A to Spoke B) must pass through the Hub’s Firewall (“East-West” traffic filtering). This gives your security team a single chokepoint to inspect, log, and control all inter-application traffic.
- No Transitivity: By default, Spoke A cannot talk to Spoke B. This provides excellent isolation for Dev/Test vs Production. A compromised dev workload cannot pivot laterally into production without going through the Hub’s firewall first.
Troubleshooting: “My VM Can’t Talk to XXX”
Networking is the most common cause of deployment failures. Experienced Azure engineers spend more time debugging networking than any other category. Use this checklist to debug systematically instead of guessing. The Golden Rule of Network Debugging: Start at the source, verify each hop, and work toward the destination. Never skip steps — the problem is almost always in the most boring, obvious place.1. The NSG Check
- Inbound vs. Outbound: Did you allow port 80 Inbound on the destination? Great. Did you also check that port 80 Outbound is allowed from the source? NSGs are applied at both ends, and the default rules block differently than you might expect.
- Priority: Is there a higher priority rule (e.g., Priority 100 Deny All) blocking your rule (Priority 200 Allow HTTP)? Lower priority numbers are evaluated first. A common mistake is adding an Allow rule at priority 200 without realizing there is a Deny All at priority 100.
- Effective Rules: Using the portal, go to the VM -> Networking -> Effective security rules. This shows the final result of ALL NSGs combined (both subnet-level and NIC-level). This is the single most useful debugging tool for NSG issues.
- NSG Flow Logs: If you need to see exactly which packets are being allowed or denied, enable NSG Flow Logs. They write to a storage account and can be analyzed with Traffic Analytics. Cost: ~$0.50/GB of log data, but invaluable for diagnosing intermittent issues.
2. The Next Hop Check
- UDRs (User Defined Routes): Is there a routing table sending your traffic to a Firewall (NVA) that is dropping it?
- VNet Peering: Is the peering status
Connected? If it’sInitiated, you forgot to create the peering link on the other side. - Transitivity: Are you trying to talk to Spoke B from Spoke A through a Hub? Remember, peering is NOT transitive. You need a device in the Hub to route the traffic.
3. The PaaS Connectivity Check
- NSG vs. Firewall: If using Service Endpoints, did you add the Subnet to the SQL/Storage firewall?
- Private DNS: If using Private Link, does
ping mystorage.blob.core.windows.netreturn a private IP or a public IP? If public, your DNS is broken.
[!TIP] Pro Tool: Connection Troubleshoot In Azure Network Watcher, use the “Connection Troubleshoot” tool. It will tell you exactly where the packet is being dropped — is it an NSG, a Route, or the OS firewall inside the VM? This is the CLI equivalent:Practical Tip: The 5-Minute Networking Debug Checklist When “My VM can’t talk to X” hits your inbox, run through this in order:The output shows every hop and where the packet was blocked. Save yourself hours of manual debugging by using this first.
- Can the VM resolve the hostname? (
nslookup target.hostfrom inside the VM) - Is the port open on the destination? (
az network nic show-effective-nsgon both source and destination) - Is there a route override? (
az network nic show-effective-route-tableon the source NIC) - Is the destination actually listening? (SSH into the destination and run
ss -tlnpornetstat -tlnp) - Is there an OS-level firewall? (Check
iptableson Linux or Windows Firewall on Windows)
Interview Deep-Dive
You are designing a network for a 3-tier web application. The security team insists on zero internet exposure for the database tier. Walk me through your VNet design.
You are designing a network for a 3-tier web application. The security team insists on zero internet exposure for the database tier. Walk me through your VNet design.
Strong Candidate Answer:
- VNet sizing: I would start with a /16 address space (10.0.0.0/16 = 65,536 addresses) even if we only need 50 addresses today. Expanding a VNet address space after peering is established is disruptive and sometimes impossible. Over-allocating IP space costs nothing in Azure.
- Subnet layout: Four subnets minimum. Public subnet (10.0.1.0/24) for the Application Gateway with WAF. Web tier subnet (10.0.2.0/24) for the frontend VMs or App Service VNet Integration. App tier subnet (10.0.3.0/24) for API servers. Database subnet (10.0.4.0/24) for the Azure SQL Private Endpoint. I would also pre-allocate a /27 for AzureBastionSubnet and a /26 for future AKS if the application might be containerized later.
- NSG strategy for zero internet exposure on DB tier: The database subnet NSG allows inbound only from the app tier subnet on port 1433 (SQL) and from the management subnet on port 1433 for DBA access. The default outbound rule is overridden with a deny-all, and a specific allow rule for Azure Monitor endpoints (for diagnostics). No internet inbound, no internet outbound.
- Private Endpoints instead of Service Endpoints: For the Azure SQL Database, I would deploy a Private Endpoint into the database subnet, giving it a private IP like 10.0.4.10. Then I disable public network access on the SQL server entirely. This means the database literally does not exist on the public internet — there is no public IP to attack.
- The DNS gotcha: After creating the Private Endpoint, your application still resolves mydb.database.windows.net to the old public IP unless you configure a Private DNS Zone (privatelink.database.windows.net) linked to the VNet. Forgetting this step means traffic goes over the public internet despite having a Private Endpoint. I have seen this misconfiguration in production audits multiple times.
Explain how NSG rules are evaluated. Two NSGs are applied -- one on the subnet and one on the NIC. A packet matches an allow rule on the subnet NSG but a deny rule on the NIC NSG. What happens?
Explain how NSG rules are evaluated. Two NSGs are applied -- one on the subnet and one on the NIC. A packet matches an allow rule on the subnet NSG but a deny rule on the NIC NSG. What happens?
Strong Candidate Answer:
- Evaluation order for inbound traffic: Subnet NSG is evaluated first, then NIC NSG. Both must allow the traffic. If the subnet NSG allows and the NIC NSG denies, the packet is dropped. Think of it as two security checkpoints in series — you must pass both.
- Evaluation order for outbound traffic: NIC NSG is evaluated first, then subnet NSG. Again, both must allow.
- Within a single NSG, rules are evaluated by priority (lowest number first). If a priority 100 rule allows port 443 from any source, and a priority 200 rule denies port 443 from a specific IP, the allow at priority 100 wins because it is evaluated first and the first match terminates evaluation.
- The stateful behavior people forget: NSGs are stateful. If you allow inbound traffic on port 443 (priority 100, inbound, allow), the return traffic (outbound response to the client) is automatically allowed regardless of outbound rules. You do not need a matching outbound rule for responses. However, if you initiate a new outbound connection (for example, your VM calling an external API), that requires an explicit outbound allow rule.
- Real-world debugging approach: When traffic is blocked and I cannot figure out why, I go to the VM’s Networking blade in the portal and click “Effective security rules.” This shows the merged result of both NSGs with the final allow/deny verdict for every rule. It has saved me hours of manual rule comparison. For intermittent issues, I enable NSG Flow Logs to capture every packet decision.
Compare the Hub-and-Spoke network topology with Azure Virtual WAN. When would you choose one over the other?
Compare the Hub-and-Spoke network topology with Azure Virtual WAN. When would you choose one over the other?
Strong Candidate Answer:
- Hub-and-Spoke (manual): You build and manage the hub VNet yourself, deploy your own Azure Firewall ($912/month) or third-party NVA, configure VNet peering manually, and manage route tables for spoke-to-spoke communication. You have full control over every routing decision and firewall rule.
- Azure Virtual WAN: Microsoft manages the hub infrastructure. You get automatic spoke-to-spoke routing (transit connectivity works out of the box), integrated VPN and ExpressRoute gateways, and a simpler management experience. The Virtual Hub cost is approximately 180/month) plus gateway and peering costs.
- Choose manual Hub-and-Spoke when: You need a third-party NVA (Palo Alto, Fortinet) instead of Azure Firewall because your security team mandates specific vendor features. You have fewer than 4 VNets and the complexity overhead of vWAN is not justified. You need fine-grained control over routing tables that vWAN abstracts away.
- Choose Virtual WAN when: You have 5+ branch offices connecting to Azure (vWAN automates SD-WAN integration). You need spoke-to-spoke transit routing without managing UDRs on every subnet. You are deploying across multiple regions (vWAN’s global transit network connects hubs automatically). You want Microsoft to handle gateway failover and routing convergence.
- The cost comparison people get wrong: vWAN looks cheaper on paper (912/month Azure Firewall), but vWAN charges separately for VPN gateway (213/month), and peering (600-900/month per hub — similar to manual hub-and-spoke. The real savings are in operational hours, not infrastructure cost.