Azure Cloud Series: This lesson is part of our comprehensive Complete Microsoft Azure Tutorial: Learn Azure from Beginner to Advanced.
Azure Network Security Groups and Application Security Groups is an important part of building reliable and secure applications on Microsoft Azure. an NSG contains ordered inbound and outbound security rules that allow or deny network traffic, while an ASG lets teams group virtual machine network interfaces by application role so NSG rules can refer to those logical groups.
The subject matters because Azure workloads communicate across subnets, services, gateways, and sometimes on-premises or public networks. A design needs to make expected paths clear while avoiding unnecessary exposure, unexplained dependencies, and operational surprises. This tutorial explains the concepts in practical language and connects them to configuration, testing, cost, and production support.
This guide uses a practical design perspective: Apply a repeatable, understandable traffic-filtering policy at subnet or network-interface boundaries without maintaining every rule against long lists of individual ip addresses. It also explains how to validate the resulting behaviour instead of assuming a resource is ready merely because deployment succeeded.
What You Will Learn
- What Azure Network Security Groups (NSGs) and Application Security Groups (ASGs) means and which problems it is designed to solve
- How the main components work together: security rules, priorities, source and destination prefixes, service tags, port ranges, protocols, inbound and outbound directions, subnet or NIC associations, and ASG membership
- How to plan and validate a deployment using the workflow: map required flows, define groups by application role, create narrowly scoped rules with unique priorities, associate the NSG to the intended boundary, inspect effective security rules, and test expected allows and denies.
- How to apply least privilege while addressing common risks such as broad allow rules, priority mistakes, duplicate or overlapping policy, assumptions about default rules, forgetting outbound behavior, and using IP-based rules where application-role grouping would be easier to maintain
- Which monitoring signals and diagnostics can help: NSG effective security rules, IP flow verification, supported NSG flow logs or traffic analytics options, application logs, and rule change review
- How to consider cost, performance, availability, and operational ownership
- How to practise in a controlled environment and troubleshoot network failures systematically
Quick Reference: Core Concepts
| Concept | Practical meaning |
|---|---|
| Primary purpose | apply a repeatable, understandable traffic-filtering policy at subnet or network-interface boundaries without maintaining every rule against long lists of individual IP addresses. |
| Key components | security rules, priorities, source and destination prefixes, service tags, port ranges, protocols, inbound and outbound directions, subnet or NIC associations, and ASG membership |
| Common design | a three-tier application in which web servers can receive HTTPS from the approved ingress tier, application servers accept only required calls from web servers, and database servers accept only database traffic from approved application identities. |
| Main operational risk | broad allow rules, priority mistakes, duplicate or overlapping policy, assumptions about default rules, forgetting outbound behavior, and using IP-based rules where application-role grouping would be easier to maintain |
| Cost drivers | NSGs and ASGs are primarily security configuration constructs; cost may arise from related monitoring, traffic analytics, appliances, firewalls, and the additional services used to operate or inspect the network. |
1. What Are Network Security Groups and Application Security Groups?
Azure Network Security Groups (NSGs) and Application Security Groups (ASGs) is best understood as part of the wider Azure network architecture, not as an isolated checkbox. In practical terms, an NSG contains ordered inbound and outbound security rules that allow or deny network traffic, while an ASG lets teams group virtual machine network interfaces by application role so NSG rules can refer to those logical groups. Teams should learn where this capability applies, which traffic or service boundary it controls, and which neighbouring controls remain responsible for access, routing, monitoring, and recovery. A correct mental model prevents common design errors, such as assuming that network reachability proves user authorisation or that a private address automatically makes a workload safe.
2. Why Does It Matter?
Cloud applications rarely operate as a single machine. They call APIs, databases, identity endpoints, monitoring services, package repositories, and other dependencies. Azure Network Security Groups (NSGs) and Application Security Groups (ASGs) helps teams build predictable paths among those components while preserving the intended boundary between public, private, and shared services. The business impact includes reliability and change safety as well as security: when a route, name, or filtering rule changes, engineers need to know which applications may be affected.
3. Key Concepts and Terminology
When working with Azure Network Security Groups (NSGs) and Application Security Groups (ASGs), keep the roles of the main building blocks separate. The components most likely to matter are security rules, priorities, source and destination prefixes, service tags, port ranges, protocols, inbound and outbound directions, subnet or NIC associations, and ASG membership. They are related, but they do different jobs: some identify an address or service, some decide where traffic goes, some allow or deny traffic, and some provide visibility into behaviour. Many outages happen when a team checks one component and assumes it represents the entire path.
How the Related Controls Differ
| Control or layer | Main responsibility | Question it answers |
|---|---|---|
| Name resolution | Maps a name to a record/address | What destination does this name represent? |
| Routing | Selects a next hop or destination path | Where does this packet go? |
| Traffic filtering | Allows or denies a flow | May this network traffic pass? |
| Service health | Shows whether a target can serve requests | Is the destination ready to handle traffic? |
| Application access | Authenticates and authorises a caller | May this identity use the requested operation? |
4. How It Fits into an Azure Architecture
A typical design uses a three-tier application in which web servers can receive HTTPS from the approved ingress tier, application servers accept only required calls from web servers, and database servers accept only database traffic from approved application identities. The request path must be valid end to end: the caller must resolve the intended name, a route must select a viable next hop, filtering controls must allow the flow, the destination must be listening and healthy, and the return traffic must be able to reach the caller. The exact set of steps depends on the service, but the principle is consistent: test the actual path rather than one component in isolation.
5. Core Components
The practical building blocks for Azure Network Security Groups (NSGs) and Application Security Groups (ASGs) include security rules, priorities, source and destination prefixes, service tags, port ranges, protocols, inbound and outbound directions, subnet or NIC associations, and ASG membership. Begin by listing which of these components exist in the target architecture and identifying their owner. The design should make clear which components are platform-managed, which require explicit configuration, and which have to be monitored or patched by the organisation. Use names and tags that reveal workload, environment, owner, and purpose; those conventions are particularly valuable when a subscription contains many similar resources.
6. Planning Before Deployment
Before creating resources, map the required flows and constraints. Confirm region, subscription ownership, address ranges, service-specific subnet requirements, expected traffic volume, regulatory boundary, and whether clients are internal, on-premises, internet-based, or in other VNets. Then decide how Azure Network Security Groups (NSGs) and Application Security Groups (ASGs) fits the architecture and identify dependencies that must exist first. The plan should also cover naming, tagging, infrastructure-as-code, approval workflows, and how the deployment will be rolled back.
7. Configuration Workflow
A controlled implementation generally follows this sequence: map required flows, define groups by application role, create narrowly scoped rules with unique priorities, associate the NSG to the intended boundary, inspect effective security rules, and test expected allows and denies. Break the work into small, verifiable changes rather than configuring many network layers at once. After every important step, test from the same client location that will be used in production and record the observed result. Where the platform supports validation, deployment what-if, policy checks, or infrastructure-as-code plans, use those controls to catch mistakes before they change live traffic.
8. Security and Least Privilege
Security design should start with explicit trust boundaries. Review broad allow rules, priority mistakes, duplicate or overlapping policy, assumptions about default rules, forgetting outbound behavior, and using IP-based rules where application-role grouping would be easier to maintain. Apply least privilege to both network traffic and management access: open only the source, destination, protocol, and port that the workload needs, and limit who can change shared routing or security controls. Do not treat the network layer as a substitute for identity, authentication, application authorisation, or encryption. A private path reduces exposure but does not remove the need for those controls.
9. Connectivity and Routing
Connectivity depends on the full traffic path, not only on the presence of a network resource. Review route selection, next-hop availability, source and destination address ranges, peering or gateway state, and the return route. If traffic passes through a firewall or appliance, confirm forwarding and return behaviour on both sides. Subnet-level versus nic-level nsg association, service tags versus explicit prefixes, asg role-based grouping versus ip lists, and central policy baselines versus narrowly scoped workload exceptions. The right answer depends on the specific requirement and should be documented rather than left to defaults that nobody has reviewed.
10. Name Resolution and Service Discovery
Names are often more stable than addresses, but they introduce another dependency. Confirm which resolver the client uses, which record should be returned from that network, whether caching affects the test, and whether private and public answers intentionally differ. For Azure Network Security Groups (NSGs) and Application Security Groups (ASGs), name resolution must match the intended route and endpoint. A client receiving a public address when the design expects a private endpoint can appear to have a routing problem even though the underlying issue is DNS.
11. Monitoring and Diagnostics
Operational visibility should tell the team what happened to a failed request and whether the fault is isolated or widespread. Useful signals can include NSG effective security rules, IP flow verification, supported NSG flow logs or traffic analytics options, application logs, and rule change review. Select telemetry that answers concrete questions: is the endpoint healthy, did a probe fail, which route was chosen, did a security control deny the flow, did DNS return the expected address, and did latency rise? Enable diagnostic settings before an outage, subject to service support and retention requirements.
12. Performance and Capacity
Networking performance is shaped by round-trip latency, bandwidth, connection count, protocol behaviour, packet processing, and the capacity of gateways or appliances in the path. For Azure Network Security Groups (NSGs) and Application Security Groups (ASGs), measure the user-visible result instead of assuming that a larger SKU or a more complex topology is automatically faster. A good performance baseline records normal latency, throughput, failed connection rate, backend health, and the path used by representative requests.
13. Availability and Failure Handling
Reliability requires an explicit answer to what happens when a component or dependency fails. For the architecture described here, identify failure modes such as unavailable endpoints, a failed gateway or appliance, a name-resolution issue, a routing mistake, and a regional disruption. Decide which dependencies need redundancy, which failures should trigger an alert, and how the application behaves when a network path is temporarily unavailable. The design should distinguish recovery within a region from recovery across regions.
14. Cost and Resource Governance
Network cost is often distributed across components rather than shown as one simple bill. Review NSGs and ASGs are primarily security configuration constructs; cost may arise from related monitoring, traffic analytics, appliances, firewalls, and the additional services used to operate or inspect the network. Estimate expected traffic, peak usage, region-to-region communication, diagnostic retention, and any idle resources. The least expensive design is not necessarily the best one if it creates unacceptable risk or operational effort, but every network component should have a stated purpose and owner.
15. Integration with Other Azure Services
Azure networking is a foundation for compute, storage, identity, monitoring, and managed platforms. The exact integration points depend on Azure Network Security Groups (NSGs) and Application Security Groups (ASGs), but the key rule is to plan the network path alongside the resource that consumes it. A private database endpoint, for example, is not complete until the consumer can resolve its name, reach its private address, pass filtering controls, and authenticate to the service. Deployment order and ownership should be documented for each dependency.
16. Practical Scenario
Consider this scenario: a multi-tier web service whose database should not be reachable from the public internet or from unrelated application subnets. Begin by drawing the request path and labeling each boundary, endpoint, and control. Define the expected source and destination, protocol, port, DNS name, route, and security decision. Then test the flow in a non-production environment and record the exact configuration that made it work. Include at least one negative test that confirms an unrelated source or destination is blocked.
17. Common Mistakes to Avoid
Common mistakes include broad allow rules, priority mistakes, duplicate or overlapping policy, assumptions about default rules, forgetting outbound behavior, and using IP-based rules where application-role grouping would be easier to maintain. A further problem is treating a successful deployment operation as equivalent to application readiness. The resource may exist while an association, route, record, health probe, security rule, or dependency remains incomplete. Teams should use pre-deployment validation and post-deployment connectivity tests to detect these conditions before users encounter them.
18. Troubleshooting Method
If a connection fails, avoid changing multiple controls at once. Start with the observed symptom and test one layer at a time: name resolution, source and destination addresses, route selection, filtering, intermediate service health, target listener, and application authorisation. For this topic, a likely failure pattern is a permitted connection is denied because a higher-priority rule blocks it or the rule is attached to the wrong boundary; alternatively, traffic succeeds unexpectedly because a broad rule overrides the intended segmentation.. Use a timestamp and the exact source endpoint so that logs and effective configuration can be correlated.
19. Pre-production Checklist
Before release, confirm that map required flows, define groups by application role, create narrowly scoped rules with unique priorities, associate the NSG to the intended boundary, inspect effective security rules, and test expected allows and denies. Check resource provisioning state, addresses, associations, route and security behaviour, DNS answers, service health, telemetry, and rollback steps. Verify that both allowed and denied flows match the documented requirement and that the team can identify the owning service and on-call contact.
Frequently Asked Questions
What is the difference between an NSG and an ASG?
An NSG applies network filtering rules. An ASG groups selected VM network interfaces into an application role so NSG rules can use those groups as sources or destinations. ASGs help make policy readable but do not filter traffic by themselves.
Can an NSG be associated with a subnet and a NIC?
Yes, NSGs can be associated at subnet and network-interface boundaries where supported. If both boundaries apply to a flow, both sets of rules matter. Teams should document the intended enforcement points and inspect effective security rules when troubleshooting.
Do NSGs include default rules?
Yes. Azure NSGs include default inbound and outbound rules, and custom rules are evaluated according to priority. Do not assume that creating one custom rule eliminates all default behavior; inspect the effective rule set for the actual interface and direction.
Are NSGs a replacement for Azure Firewall or WAF?
No. NSGs filter network traffic using properties such as IP prefixes, ports, protocol, and direction. Azure Firewall provides broader network security and inspection functions, while a web application firewall targets HTTP application threats. Use controls together when the threat model requires them.
Why does a connection fail even though an allow rule exists?
Verify the rule priority, association, source and destination match, protocol and port, route, and any second NSG or firewall. Confirm the application is listening and the return path works. Use effective security rules and IP flow verification rather than reviewing only one rule.
Should inbound and outbound rules both be reviewed?
Yes. Network security design includes both ingress and egress. A secure inbound path can still allow unintended outbound communication, and a restrictive outbound rule can break required dependencies. Document expected flows in both directions and test them after changes.
Conclusion
Azure Network Security Groups (NSGs) and Application Security Groups (ASGs) should be treated as a deliberate architecture and operational choice, not a one-time deployment task. The central objective is to apply a repeatable, understandable traffic-filtering policy at subnet or network-interface boundaries without maintaining every rule against long lists of individual IP addresses. That requires a clear understanding of the request path, careful configuration, monitoring that supports diagnosis, and tests that prove both permitted and denied traffic behave as expected.
Before production use, verify current Microsoft documentation for supported regions, service tiers, quotas, subnet requirements, and billing. Keep network diagrams and runbooks in step with changes, and test recovery rather than assuming a configuration will work under failure conditions.
20. Security Fundamentals
Security for Azure Network Security Groups (NSGs) and Application Security Groups (ASGs) depends on layered controls and carefully defined ownership. Apply network segmentation, restrict public exposure, review who can alter routing or security resources, and protect management interfaces. Use the least-privilege rule for each source, destination, port, and protocol. Network controls should complement authentication, authorisation, encryption, and secure application design rather than replace them.
21. Additional Limitations and Operational Considerations
Important constraints include NSGs are stateful packet filters, not full application firewalls. They do not replace identity checks, service-level authorisation, DDoS protection, or central inspection required by a security architecture. Rule limits and supported references should be checked in current documentation. Always validate current regional availability, quotas, SKU support, subnet constraints, and the service-specific requirements for the exact resource being deployed. A design that works for one Azure service may not transfer directly to another because their routing, DNS, and outbound connectivity models can differ.
22. Recommended Learning Path
Use this sequence to build practical understanding of Azure Network Security Groups (NSGs) and Application Security Groups (ASGs):
1. Learn the purpose and core terminology before changing production settings.
2. Draw the expected request path and identify each routing, filtering, and name-resolution dependency.
3. Deploy a small lab using a reviewed template or carefully documented portal steps.
4. Test a successful connection and at least one intentionally blocked connection.
5. Practise troubleshooting and record the result, then clean up unused resources.
23. Service Selection and Architecture Thinking
Choose a network pattern by starting from the application requirement, not from a favourite Azure service. Compare subnet-level versus NIC-level NSG association, service tags versus explicit prefixes, ASG role-based grouping versus IP lists, and central policy baselines versus narrowly scoped workload exceptions. Consider who owns the control, what traffic it sees, what happens if it fails, and how the team will diagnose an incident. Avoid adding a gateway, appliance, or extra network boundary unless it provides a clear security, connectivity, or resilience benefit.
24. Scalability and Performance
As usage increases, validate address capacity, connection patterns, service limits, and network component throughput. Monitor the actual workload and baseline normal behaviour before changing SKUs or introducing more layers. For Azure Network Security Groups (NSGs) and Application Security Groups (ASGs), performance problems can result from a permitted connection is denied because a higher-priority rule blocks it or the rule is attached to the wrong boundary; alternatively, traffic succeeds unexpectedly because a broad rule overrides the intended segmentation. as well as from resource capacity. Separate network latency from backend processing and DNS delays using timestamps and targeted tests.
25. Reliability and Recovery
Reliability requires a documented response to the failure of a route, gateway, endpoint, resolver, appliance, or dependent service. Map critical dependencies, alert on health indicators that affect users, and define who owns recovery. For Azure Network Security Groups (NSGs) and Application Security Groups (ASGs), do not assume redundancy is effective because a secondary resource exists; verify that routing, policy, DNS, and application settings can actually direct traffic to it.
26. Hands-on Practice and Production Thinking
Build a safe lab around a multi-tier web service whose database should not be reachable from the public internet or from unrelated application subnets. Document the resource layout, address and naming choices, route and filtering requirements, diagnostic signals, estimated cost drivers, and cleanup procedure. Create a test matrix with expected successful and denied flows, then compare expected results with actual observations. The goal is to practise repeatable operation, not only a one-time successful connection.
Related Azure Topics
Related topics include Azure Virtual Network (VNet), Subnets and Route Tables, Network Egress and NAT Gateway, Load Balancer and Application Gateway, and Azure Networking Best Practices. Security rules are most useful when they are designed together with the route and application dependency model.
References and Further Reading
Use Microsoft Learn as the source of truth for current feature behavior, supported configurations, quotas, security recommendations, and regional availability. Check service-specific requirements before applying a pattern to production.
- https://learn.microsoft.com/en-us/azure/virtual-network/network-security-groups-overview
- https://learn.microsoft.com/en-us/azure/virtual-network/application-security-groups
- https://learn.microsoft.com/en-us/azure/network-watcher/network-watcher-ip-flow-verify-overview
Canonical URL: https://kodestree.com/azure-nsg-asg/