Azure NSG vs ASG

In cloud networking, firewalls and access control are your first line of defense.
In Azure, the two main tools for this are:

  • Network Security Group (NSG)
  • Application Security Group (ASG)

Let’s explore what they are, how they work, and how to use them together.

What is a Network Security Group (NSG)?

An NSG acts like a virtual firewall. You can apply it to:

  • Subnets
  • Network interfaces (NICs)

NSG Rules look like:

PriorityDirectionSourceDestinationPortAction
100InboundAny10.0.1.480Allow
200InboundAnyAny*Deny

Azure processes rules top-down, based on priority (lower = higher priority).

How NSGs Work

  • You can associate an NSG to:
    • A subnet → all resources in that subnet
    • A NIC → specific VM or resource
  • Rules are stateful — response traffic is allowed automatically.

What is an Application Security Group (ASG)?

ASGs are labels or tags that group VMs logically. Think of them like virtual “security groups” for workloads.

You use ASGs inside NSG rules to simplify targeting.

Example:

RuleSource ASGDestination ASGPortAction
100web-serversdb-servers1433Allow

ASG lets you manage security at scale without tracking IPs.

NSG vs ASG: What’s the Difference?

FeatureNSGASG
TypeFirewallLogical group/tag
Applies toSubnets, NICsOnly used inside NSG rules
ManagesAccess rulesTargets inside NSG rules
ExampleAllow port 80 to 10.0.1.4Allow traffic to web-servers ASG

Best Practices

  • Use NSGs for all subnets — even private ones
  • Use ASGs to group workloads (e.g., web-tier, db-tier)
  • Don’t use public IPs in rules — use ASGs or service tags
  • Always deny all at end unless explicitly required

Learn More

Next: Azure Firewall, DDoS Protection, and network security design patterns

– Kasi @ KasdevTech or LinkedIn