Study guide
8.1 Network Security Groups (NSGs) & Application Security Groups (ASGs)
Designing and Implementing Microsoft Azure Networking Solutions AZ-700
Track your progress as you read
Finished sections get a check mark.
1 Introduction & AZ-700 Exam Overview
0.1 About the AZ-700 Exam: Format, Scoring & Skills Measured
2 Chapter 1: Azure Virtual Networks, Addressing & Subnet Architecture
1.1 VNet Planning, IP Addressing & Subnet Design 1.2 Virtual Network Peering & Global Peering 1.3 Azure NAT Gateway & Outbound Connectivity 1.4 Azure Virtual Network Manager (AVNM) & Network Groups 1.5 Public IP Addresses, Public IP Prefixes & Custom IP Prefixes (BYOIP)
3 Chapter 2: Azure Name Resolution & Core Routing
2.1 Azure DNS & Private DNS Zones 2.2 Azure Private DNS Resolver & Hybrid Name Resolution 2.3 System Routes & User-Defined Routes (UDR) 2.4 BGP & Custom Route Propagation 2.5 Azure Route Server & Dynamic NVA Route Exchange
4 Chapter 3: Hybrid Connectivity with Azure VPN Gateway
3.1 Azure VPN Gateway Architecture & SKUs 3.2 Site-to-Site (S2S) VPN & High Availability 3.3 Point-to-Site (P2S) VPN & Client Authentication 3.4 Azure Extended Network, Always On VPN & Azure Network Adapter
5 Chapter 4: Azure ExpressRoute & Virtual WAN
4.1 Azure ExpressRoute Architecture & Peering Models 4.2 ExpressRoute Routing, Resiliency & Global Reach 4.3 Azure Virtual WAN Architecture & Hub Routing 4.4 ExpressRoute BFD, Monitoring & Connection Troubleshooting
6 Chapter 5: Regional Load Balancing & Application Gateway
5.1 Azure Load Balancer Architecture & Rules 5.2 Azure Application Gateway Architecture & Routing 5.3 Web Application Firewall (WAF) on Application Gateway 5.4 Inbound NAT Rules, Port Forwarding & Health Probe Design
7 Chapter 6: Global Traffic Management & Azure Front Door
6.1 Azure Front Door Architecture & Routing 6.2 Azure Traffic Manager & DNS Load Balancing 6.3 Load Balancing Decision Matrix & Multi-Tier Design 6.4 Web Application Firewall on Azure Front Door
8 Chapter 7: Azure Private Link & Service Endpoints
7.1 Virtual Network Service Endpoints & Policies 7.2 Azure Private Endpoints & Private Link Architecture 7.3 Private Endpoint DNS Integration & Hybrid Resolution 7.4 Azure Private Link Service for Multi-Tenant Solutions
9 Chapter 8: Network Security Groups & Azure Bastion
8.1 Network Security Groups (NSGs) & Application Security Groups (ASGs) 8.2 Azure Bastion Architecture & Secure Remote Access 8.3 Azure Virtual Network Manager Security Admin Rules
10 Chapter 9: Azure Firewall & Security Policies
9.1 Azure Firewall Architecture & Rule Processing 9.2 Azure Firewall Manager & DDoS Protection
11 Chapter 10: Azure Network Observability & Troubleshooting
10.1 Network Watcher Diagnostic Tools 10.2 NSG Flow Logs, VNet Flow Logs & Traffic Analytics 10.3 Network Troubleshooting Scenarios & End-to-End Connectivity 10.4 Azure Monitor Network Insights & Defender for Cloud Network Posture
8.1 Network Security Groups (NSGs) & Application Security Groups (ASGs)
Key Takeaways Explain This Topic AI
Network Security Groups (NSGs) enforce stateful 5-tuple packet filtering (Source IP, Source Port, Destination IP, Destination Port, Protocol) where return traffic is automatically allowed for established flows via connection tracking.
Inbound traffic is evaluated at the Subnet NSG first, then the NIC NSG; outbound traffic is evaluated at the NIC NSG first, then the Subnet NSG—traffic is dropped if blocked at either tier.
Default NSG rules cannot be deleted but are overridden by custom rules with priorities 100 to 4096 (lower numbers evaluated first); defaults include 65000 AllowVnetInBound/OutBound, 65001 AllowAzureLoadBalancerInBound/AllowInternetOutBound, and 65500 DenyAllInBound/DenyAllOutBound.
Application Security Groups (ASGs) group virtual machine network interfaces into logical application tiers (e.g., Web, App, DB), enabling dynamic microsegmentation within a VNet without updating IP addresses in NSG rules.
Augmented security rules allow specifying multiple IP addresses, CIDR ranges, port lists (e.g., 80, 443, 8080-8090), and service tags in a single rule, preventing rule exhaustion and simplifying security policy management.
Last updated: August 2026
Network Security Groups (NSGs) & Application Security Groups (ASGs)
In Microsoft Azure Software-Defined Networking (SDN), Network Security Groups (NSGs) serve as the primary Layer 3 and Layer 4 distributed firewall mechanism. Operating directly within the Azure Virtual Filtering Platform (VFP) hypervisor layer, NSGs filter ingress and egress traffic traversing subnets and virtual machine network interfaces (NICs).
Modern cloud network security demands granular access control, high throughput, and zero-trust microsegmentation. By combining NSGs with Application Security Groups (ASGs) , Service Tags , and Augmented Security Rules , network architects can construct scalable security perimeters that automatically adapt to dynamic workload lifecycles without requiring tedious, manual IP address reconfigurations.
1. NSG Fundamentals & 5-Tuple Stateful Inspection
An NSG contains a list of Access Control List (ACL) rules that allow or deny network traffic based on a 5-tuple inspection model:
- Source IP Address / Prefix (or Service Tag / Application Security Group)
- Source Port / Port Range (typically an ephemeral port range such as * or 1024-65535 )
- Destination IP Address / Prefix (or Service Tag / Application Security Group)
- Destination Port / Port Range (e.g., 80 , 443 , 1433 , 8080-8090 )
Protocol ( TCP , UDP , ICMP , ESP , AH , or Any / * ) +-----------------------------------------------------------------------------+
- | 5-TUPLE STATEFUL PACKET FILTERING |
- | |
- | Inbound Packet Header: |
- | [ Src IP: 198.51.100.25 ] [ Src Port: 51240 ] |
- | [ Dst IP: 10.0.1.4 ] [ Dst Port: 443 ] [ Protocol: TCP ] |
- | |
- | Azure Virtual Filtering Platform |
- | | |
- | Matches NSG Rule: Priority 100 (Allow) |
- | | |
- | v |
- | +---------------------------+ |
- | | VFP State Flow Table | |
- | | - Flow: Established | |
- | | - Auto-Allow Return Flow | |
- | +---------------------------+ |
- | | |
- | v |
- | Outbound Return Packet: |
- | [ Src IP: 10.0.1.4 ] [ Src Port: 443 ] |
- | [ Dst IP: 198.51.100.25 ] [ Dst Port: 51240 ] [ Protocol: TCP ] |
- | --> AUTOMATICALLY PERMITTED (Bypasses Outbound NSG Rule Evaluation) |
- +-----------------------------------------------------------------------------+
- Stateful Connection Tracking
Azure NSGs are fully stateful :
When an inbound packet is permitted by an NSG rule, the Azure SDN fabric creates an active connection tracking entry in its state flow table.
All return traffic belonging to that established session is automatically allowed, regardless of any conflicting outbound NSG rules.
Similarly, if an outbound connection is initiated by a VM and permitted by an outbound NSG rule, all inbound response packets for that flow are automatically allowed, bypassing inbound NSG rules.
Stateful tracking applies to TCP sessions (tracking SYN, ACK, FIN/RST sequences) and UDP/ICMP pseudo-connections (tracked via source/destination IP and port timers).
Note
Because NSGs are stateful, you do not need to open high-numbered ephemeral return ports (e.g., ports 1024–65535) in the opposite direction. Doing so introduces severe security vulnerabilities.
2. Two-Tier Association & Rule Evaluation Order
Network Security Groups can be associated at two distinct scopes within an Azure Virtual Network:
Subnet Scope: Associated directly to a subnet, filtering all traffic entering or leaving any network interface located in that subnet.
Network Interface (NIC) Scope: Associated directly to a specific VM network interface, applying filtering exclusively to that individual NIC. +-----------------------------------------------------------------------------+
- | TWO-TIER NSG EVALUATION ARCHITECTURE |
- | |
- | INBOUND TRAFFIC FLOW: |
- | External / VNet Packet |
- | | |
- | v |
- | [ 1. Subnet NSG Inbound ] ---> If DENY ---> [ Packet DROPPED ] |
- | | (If ALLOW) |
- | v |
- | [ 2. NIC NSG Inbound ] ---> If DENY ---> [ Packet DROPPED ] |
- | | (If ALLOW) |
- | v |
- | [ Virtual Machine OS ] |
- | |
- | ----------------------------------------------------------------------- |
- | |
- | OUTBOUND TRAFFIC FLOW: |
- | Virtual Machine OS |
- | | |
- | v |
- | [ 1. NIC NSG Outbound ] ---> If DENY ---> [ Packet DROPPED ] |
- | | (If ALLOW) |
- | v |
- | [ 2. Subnet NSG Outbound] ---> If DENY ---> [ Packet DROPPED ] |
- | | (If ALLOW) |
- | v |
- | Destination Network / Internet |
- +-----------------------------------------------------------------------------+
- The Two-Tier Evaluation Sequence
Traffic evaluation depends strictly on the direction of packet traversal:
Inbound Evaluation Sequence:
The packet first encounters the Subnet-level NSG . Rules are processed in priority order (100–4096). If a matching rule Denies the packet, it is dropped immediately. If allowed, evaluation proceeds to step 2.
The packet then encounters the NIC-level NSG . Rules are processed in priority order. If a matching rule Denies the packet, it is dropped. If allowed by both tiers, the packet reaches the VM operating system.
Outbound Evaluation Sequence:
The egress packet leaving the VM OS first encounters the NIC-level NSG . If denied, it is dropped immediately.
If permitted by the NIC NSG, the packet encounters the Subnet-level NSG . If denied by the subnet NSG, it is dropped. If permitted by both tiers, the packet departs the subnet.
Intra-Subnet Traffic Evaluation
When two virtual machines reside within the same subnet protected by a Subnet NSG:
Outbound traffic from VM-1 is evaluated by VM-1's NIC NSG (outbound) -> Subnet NSG (outbound).
Inbound traffic arriving at VM-2 is evaluated by Subnet NSG (inbound) -> VM-2's NIC NSG (inbound).
If the Subnet NSG contains a rule blocking intra-subnet communication, packets between VM-1 and VM-2 are dropped at the Subnet NSG tier even though no router or gateway is involved.
Loading diagram... Two-Tier NSG Inbound and Outbound Evaluation Hierarchy
3. Default NSG Rules & Priority Processing
Every NSG created in Azure is automatically provisioned with six default security rules (three inbound and three outbound). Default rules ensure basic platform operability and provide a secure fallback posture.
Inbound Default Security Rules
- Priority Rule Name Source Source Port Destination Destination Port Protocol Access
- 65000 AllowVnetInBound VirtualNetwork * VirtualNetwork * * Allow
- 65001 AllowAzureLoadBalancerInBound AzureLoadBalancer * * * * Allow
- 65500 DenyAllInBound * * * * * Deny
- Outbound Default Security Rules
- Priority Rule Name Source Source Port Destination Destination Port Protocol Access
- 65000 AllowVnetOutBound VirtualNetwork * VirtualNetwork * * Allow
- 65001 AllowInternetOutBound * * Internet * * Allow
- 65500 DenyAllOutBound * * * * * Deny
- Custom Rule Priorities & Immutability
Priority Range: Custom security rules can be assigned integer priorities from 100 to 4096 .
Processing Sequence: Rules are evaluated strictly in ascending order (priority 100 is evaluated before priority 200). Once a packet matches a rule's 5-tuple criteria, processing terminates immediately ; subsequent rules are ignored.
Immutability of Default Rules: Default rules (priorities 65000, 65001, 65500) cannot be deleted or modified . However, because custom rules have lower priority numbers (100–4096), you can easily override any default rule by creating a higher-priority custom rule (e.g., a custom outbound rule with Priority 4000 denying all traffic to the Internet service tag overrides rule 65001).
Caution
Overriding AllowAzureLoadBalancerInBound: If you create a custom inbound Deny rule that inadvertently blocks the AzureLoadBalancer service tag (infrastructure IP 168.63.129.16 ), health probes from Azure Load Balancer will fail, causing backend pools to mark your VMs unhealthy and terminating traffic routing.
4. Augmented Security Rules
Historically, creating complex firewall policies required defining a separate NSG rule for every IP address, port, and protocol combination. This quickly led to sprawling rule sets that exceeded Azure's platform limits (maximum 1,000 rules per NSG).
Augmented Security Rules allow you to bundle complex multidimensional policies into a single, cohesive rule definition:
Multiple IP Addresses & CIDR Ranges: A single rule can specify multiple comma-separated IP addresses and CIDR prefixes in the source or destination field (e.g., 10.0.1.0/24, 10.0.2.0/24, 192.168.10.50/32, 172.16.0.0/16 ).
Multiple Port Ranges: A single rule can specify multiple individual ports and port ranges (e.g., 80, 443, 8080-8085, 9000 ).
Combined Service Tags: Multiple service tags can be referenced within a single rule definition. // Example: Augmented NSG Rule in ARM / Bicep format
- {
- "name": "Allow-Web-Management-Ports",
- "properties": {
- "protocol": "Tcp",
- "sourcePortRange": "*",
- "destinationPortRanges": ["80", "443", "8080-8090", "9443"],
- "sourceAddressPrefixes": ["10.10.0.0/16", "192.168.5.0/24", "203.0.113.10/32"],
- "destinationAddressPrefix": "*",
- "access": "Allow",
- "priority": 150,
- "direction": "Inbound"
- }
- }
- 5. Application Security Groups (ASGs) & Dynamic Microsegmentation
Application Security Groups (ASGs) provide an abstraction layer that decouples network security policy from physical IP addressing. An ASG is an SDN object that groups virtual machine network interfaces (NICs) under a logical workload identifier. +-----------------------------------------------------------------------------+
- | APPLICATION SECURITY GROUP (ASG) ARCHITECTURE |
- | |
- | Virtual Network: 10.100.0.0/16 |
- | |
- | +--------------------------+ +--------------------------+ |
- | | ASG: ASG-WebTier | | ASG: ASG-AppTier | |
- | | - Web-VM1 NIC (10.0.1.4) | | - App-VM1 NIC (10.0.1.6) | |
- | | - Web-VM2 NIC (10.0.1.5) | | - App-VM2 NIC (10.0.1.7) | |
- | +--------------------------+ +--------------------------+ |
- | | | |
- | v v |
- | +---------------------------------------------------------------------+ |
- | | NSG Rule (Priority 120): Allow-Web-to-App | |
- | | - Source: ASG-WebTier | |
- | | - Destination: ASG-AppTier | |
- | | - Destination Port: 8443 (TCP) | |
- | | - Action: Allow | |
- | +---------------------------------------------------------------------+ |
- | |
- | Benefit: When Web-VM3 or App-VM3 scales up and joins the ASG, |
- | security policies apply instantly with ZERO NSG rule changes! |
- +-----------------------------------------------------------------------------+
- How ASGs Enable Zero-Trust Microsegmentation
Consider a classic three-tier application (Web, Application, Database) hosted in the same subnet or across multiple subnets:
Create three ASGs: ASG-Web , ASG-App , and ASG-DB .
Assign the network interfaces of web VMs to ASG-Web , application VMs to ASG-App , and database VMs to ASG-DB .
Define granular NSG rules referencing ASGs directly:
Rule 110: Inbound Allow from Internet to ASG-Web on ports 80, 443 .
Rule 120: Inbound Allow from ASG-Web to ASG-App on port 8443 .
Rule 130: Inbound Allow from ASG-App to ASG-DB on port 1433 .
Rule 140: Inbound Deny from ASG-Web to ASG-DB on * (Explicit isolation).
ASG Rules and Constraints
Single VNet Boundary: All network interfaces assigned to an ASG must reside within the same Virtual Network where the ASG is created. You cannot assign NICs from different VNets to the same ASG.
Multiple ASG Memberships: A single network interface can be assigned to multiple ASGs (up to platform limits, typically 20 ASGs per NIC).
NSG Rule Scoping: An NSG rule can specify ASGs as both the source and destination, provided both ASGs reside within the same VNet as the network interfaces being protected.
No Cross-VNet Peering in Rules: You cannot use an ASG in an NSG rule to filter traffic originating from or destined to a peered VNet (cross-VNet filtering requires IP prefixes or service tags).
6. Service Tags & Platform Infrastructure VIPs
A Service Tag is a platform-managed label that represents a group of IP address prefixes associated with a specific Azure service or platform function. Microsoft automatically updates the IP prefixes included in a service tag as service topologies change.
Essential Service Tags for AZ-700
Service Tag Name Scope & IP Address Space Included Common Usage Scenario
VirtualNetwork Includes the local VNet address space , all peered VNets , connected on-premises VPN/ExpressRoute address spaces , and VNet Service Endpoint prefixes. Default intra-network communication rules (65000).
AzureLoadBalancer Resolves to the Azure platform infrastructure health probing IP 168.63.129.16 . Inbound health probes from Standard and Basic Load Balancers.
Internet Represents all public IP address space outside the virtual network and Azure datacenter management ranges. Controlling outbound web access and inbound public ingress.
AzureCloud Represents all public IP addresses across all Azure datacenters globally (can be scoped regionally, e.g., AzureCloud.EastUS ). Secure communication to Azure PaaS backends without opening public Internet.
Storage Represents all Azure Storage public IP endpoints globally (or regionally, e.g., Storage.WestUS ). Permitting VM access to Blob/Table/Queue storage over Service Endpoints or public IPs.
Sql Represents Azure SQL Database, Azure SQL Managed Instance, and Azure Synapse endpoints. Allowing application tiers to reach Azure SQL services.
AzureKeyVault Represents Azure Key Vault endpoints. Allowing workload VMs to retrieve secrets, keys, and certificates.
GatewayManager Represents Azure control plane management endpoints for VPN Gateway, Application Gateway, and Azure Bastion. Mandatory inbound management rules on specialized subnets.
Important
The VirtualNetwork Service Tag Scope: On the AZ-700 exam, remember that VirtualNetwork is not restricted to the single local VNet. It encompasses all address spaces reachable via VNet Peering, Virtual Network Gateways, and active Service Endpoints.