Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

3.1.1. Network Security Groups (NSGs) and Application Security Groups (ASGs)

💡 First Principle: NSGs filter network traffic using rules based on source, destination, port, and protocol. They operate at Layer 3-4 (network/transport) and can be applied to subnets or individual NICs.

Scenario: You have a three-tier application with web, application, and database tiers. Web servers should accept traffic from the internet on port 443; application servers should only accept traffic from web servers; database servers should only accept traffic from application servers.

NSG Rule Components

PropertyDescriptionExample
PriorityLower number = higher priority (100-4096)100
SourceWhere traffic originatesIP, CIDR, Service Tag, ASG
Source portOriginating port* (any)
DestinationWhere traffic goesIP, CIDR, Service Tag, ASG
Destination portTarget port443
ProtocolTCP, UDP, ICMP, AnyTCP
ActionAllow or DenyAllow

Application Security Groups (ASGs)

  • Purpose: Logical grouping of VMs for simplified NSG rules
  • Benefit: Use application-centric names instead of IP addresses
  • Example: "WebServers" ASG instead of listing individual IPs
Visual: NSG with ASGs

💡 Key Insight: NSG rules reference ASG names ("WebServers", "DBServers") instead of IP addresses. When VMs join an ASG, they automatically inherit all rules—no IP management required.

Default NSG Rules

PriorityNameDirectionAction
65000AllowVnetInboundInboundAllow
65001AllowAzureLoadBalancerInboundInboundAllow
65500DenyAllInboundInboundDeny
65000AllowVnetOutboundOutboundAllow
65001AllowInternetOutboundOutboundAllow
65500DenyAllOutboundOutboundDeny

⚠️ Exam Trap: Forgetting that NSGs have default rules. The default "AllowVnetInbound" rule allows all traffic within the VNet. If you need to isolate subnets from each other, you must add explicit deny rules with lower priority numbers.

Alvin Varughese
Written byAlvin Varughese
Founder15 professional certifications