Recommend a Solution to Optimize Network Security — Lesson
AZ-305 › Unit 4: Design infrastructure solutions › Design network solutions › Recommend a solution to optimize network security
Recommend a Solution to Optimize Network Security — Lesson
A large regulated bank's annual penetration test report lands on the architect's desk. The findings are extensive: VMs in production with NSGs allowing the internet ($0.0.0.0/0$) inbound on common admin ports such as RDP 3389 and SSH 22; no central egress filtering or auditing of outbound traffic; storage accounts and SQL databases with public endpoints reachable from anywhere on the internet with only allow-list firewall rules; a flat VNet topology with no internal segmentation, so any compromised VM can reach every other VM laterally. The architect's six-month remediation programme systematically rewrites the security posture from end to end: every Azure PaaS backend is moved onto a Private Endpoint with public network access disabled; a hub-based Azure Firewall Premium with TLS inspection and IDPS enabled becomes the single egress chokepoint; NSGs and Application Security Groups segment workloads at the subnet and NIC level by role rather than by CIDR; DDoS Network Protection is enabled on the VNets hosting tier-1 public IPs; Azure WAF policies are enabled on every public Application Gateway and at the Front Door edge. The next year's pen test report is one page long with no critical findings. This lesson is about deliberately designing network-layer security — layered, defence-in-depth, identity-aware, Zero-Trust-aligned — instead of relying on perimeter firewall alone or a single magic security product.
We will work through Azure's network-security story in the order the AZ-305 exam expects you to think about it: NSGs and ASGs at the segmentation layer, Azure Firewall Standard / Premium / Basic at the egress layer, DDoS Protection at the network edge, Azure WAF on Application Gateway and Front Door at the L7 layer, and Private Link / Private Endpoints / service endpoints at the PaaS perimeter. Reference: the AZ-305 exam study guide, particularly Chapter 4 Skill $4.4 on network security and the Microsoft Zero Trust architecture documentation.
Why This Matters
Network security is the foundation of any defensible Azure architecture and the most visible part of a customer's posture during audit reviews. Misconfigured, network security is the failure mode that lands a customer in a public breach disclosure or a regulator's escalation queue. The AZ-305 exam tests this LO heavily because architects make most network-security choices at design time — choices that set the security ceiling for the workload's lifetime and are operationally difficult to add after the fact.
The career payoff is concrete: every pen-test remediation programme, every "we just got SOC2 audit findings" project, every Zero-Trust transformation programme, every regulated workload's design review, every "why did we fail this audit?" retrospective, and every cyber-incident response touches this LO at some point in the workload's life. If you can match a security requirement to the right Azure service and layer the controls correctly across edge, regional, segmentation, PaaS, egress, and admin tiers, you will pass this slice of the exam and design network security like a senior architect — turning audit findings from inevitable to rare.
Prerequisites
- NSG basics. Can you describe rule precedence (lower priority = higher priority)? — Self-check: what's the default outbound rule?
- TCP / UDP. Are you familiar with stateful vs stateless connections? — Self-check: which is firewalled most easily?
- TLS basics. Do you understand TLS termination vs passthrough? — Self-check: when does TLS inspection require certificate trust?
- Private endpoint concept. Have you used Private Endpoints? — Self-check: which DNS zone does Private Link populate?
- Defence-in-depth. Are you familiar with the concept? — Self-check: name three layers in a layered network defence.
If any of these feels shaky, pause and review LO-8 (secrets/keys), LO-45 (internet connectivity), and LO-11 (identity governance) before continuing this lesson on network security.
Learning Objectives
- Analyse a workload's security requirements (perimeter, micro-segmentation, egress filtering, DDoS, application-layer threats) and translate them to the right Azure services.
- Recommend NSG vs ASG vs Azure Firewall placement for a given segmentation need, including hub-spoke routing patterns.
- Design a Private Endpoint topology that removes public access from PaaS resources and pair it with the right private DNS plumbing.
- Configure Azure Firewall (Standard / Premium / Basic) for centralised egress filtering, with TLS inspection and IDPS where appropriate.
- Deploy WAF policies on Application Gateway and Front Door for OWASP protection, bot management, and geo / IP restrictions.
- Recognise anti-patterns — flat VNet, public PaaS endpoints, no DDoS Network Protection, NSG rules with $0.0.0.0/0$ on admin ports, missing WAF in front of public apps — and rewrite each one.
Building Blocks
NSG (Network Security Group) — Stateful 5-tuple ACL at the NIC or subnet level. Formally, Microsoft.Network/networkSecurityGroups with inbound + outbound rules ordered by priority (100 – 4096, lower = higher priority). It matters because NSGs are the first line of segmentation inside a VNet.
ASG (Application Security Group) — A logical grouping of NICs by application role. Formally, Microsoft.Network/applicationSecurityGroups referenced from NSG rules. Lets rules use ASG names instead of CIDRs. It matters because ASGs make NSG rules readable and decouple them from IP changes.
Azure Firewall — Managed stateful L3/L4/L7 firewall. Tiers Basic / Standard / Premium. Premium adds TLS inspection, IDPS, URL filtering. Sits in a hub VNet; UDRs force spoke egress through it. It matters because Azure Firewall is the canonical egress / inter-spoke filtering point.
Azure DDoS Protection — Network Protection (paid) and Basic (free, always-on). Network Protection adds adaptive tuning, attack analytics, and cost protection. Per-VNet pricing. It matters because basic protects against most volumetric attacks; Network Protection is required for tier-1 workloads.
Azure WAF — Web Application Firewall on Application Gateway or Front Door. Formally, OWASP CRS-based rule sets + custom rules + bot management. Detects SQL injection, XSS, command injection, etc. It matters as the L7 defence layer for HTTP workloads.
Private Link / Private Endpoint — Bring PaaS services onto a private IP in your VNet. Formally, Microsoft.Network/privateEndpoints linking to a resource (storageAccount, sql server, cosmos account, etc.) and a privateDnsZoneGroup for DNS resolution. It matters because Private Endpoint removes the PaaS service from the public internet entirely.
Service endpoint — Older mechanism that adds a VNet attribute to a PaaS service's firewall, restricting access by VNet identity. Subnet-level. Largely superseded by Private Endpoint for new designs but still in use.
Zero Trust — A security philosophy: never trust based on network position; always verify identity. Formally, "assume breach", verify every access request, enforce least privilege. It matters because Zero Trust drives the move from perimeter security to identity-based controls.
Microsoft Defender for Cloud — Continuous security posture management across Azure. Detects misconfigured NSGs, public endpoints, missing DDoS protection, etc. It matters because Defender produces the prioritised remediation backlog that drives ongoing security work.
Deep Dive
1. The defence-in-depth stack
Network security is layered, not single-line. Each layer covers what the others miss.
| Layer | Service(s) | Threat class |
|---|---|---|
| Edge (global) | Front Door + WAF + DDoS Premium | Volumetric / OWASP / bot |
| Edge (regional) | Application Gateway + WAF | Regional L7 attack |
| Egress | Azure Firewall (Premium for TLS / IDPS) | Outbound C2, data exfil, IDPS |
| Segmentation | NSG / ASG on subnets and NICs | Lateral movement |
| PaaS perimeter | Private Endpoint + denying public access | Public-internet PaaS attack |
| Admin | Bastion + PIM + Conditional Access | Credential-based attacks |
[!IMPORTANT] Removing any single layer creates a gap. Production architectures should have all six layers in place even if some are minimal (e.g., Defender free tier rather than Defender for Servers), so that no single misconfiguration creates a complete bypass.
2. NSGs and ASGs — segmentation done right
| Concept | When |
|---|---|
| NSG at subnet | Default position; applies to all NICs in the subnet |
| NSG at NIC | Overrides subnet NSG; rarely used; complicates audit |
| ASG | Group NICs by role (e.g., asg-web, asg-db); reference in NSG rules instead of CIDRs |
resource asgWeb 'Microsoft.Network/applicationSecurityGroups@2024-03-01' = {
name: 'asg-web'
location: location
}
resource asgDb 'Microsoft.Network/applicationSecurityGroups@2024-03-01' = {
name: 'asg-db'
location: location
}
resource nsg 'Microsoft.Network/networkSecurityGroups@2024-03-01' = {
name: 'nsg-app'
location: location
properties: {
securityRules: [
{
name: 'AllowWebToDB'
properties: {
priority: 100
direction: 'Inbound'
access: 'Allow'
protocol: 'Tcp'
sourceApplicationSecurityGroups: [{ id: asgWeb.id }]
destinationApplicationSecurityGroups: [{ id: asgDb.id }]
destinationPortRanges: ['1433']
}
}
{
name: 'DenyAllInbound'
properties: { priority: 4096, direction: 'Inbound', access: 'Deny', protocol: '*', sourceAddressPrefix: '*', destinationAddressPrefix: '*' }
}
]
}
}[!TIP] Use ASGs everywhere. Reference roles, not IPs. When a VM moves between subnets, the ASG follows; when an IP changes, the rule still applies.
3. Azure Firewall — egress + inter-spoke control
The hub-spoke pattern places Azure Firewall in the hub VNet; spoke subnets have UDRs that point egress traffic to the firewall's private IP.
| Tier | Capabilities |
|---|---|
| Basic | L3/L4; small workloads; up to 250 Mbps |
| Standard | + L7 FQDN filtering, threat intelligence |
| Premium | + TLS inspection, IDPS, URL filtering, web categories |
[!WARNING] TLS inspection on Premium tier requires distributing a trusted CA to clients. Some workloads (mobile clients with cert pinning) cannot have inspected TLS — exempt them via Firewall rules.
4. WAF on App Gateway and Front Door
| Aspect | App Gateway WAF v2 | Front Door WAF (Premium) |
|---|---|---|
| Scope | Regional | Global (AnyCast edge) |
| Rule sets | OWASP CRS $3.x$ + custom | OWASP CRS + Microsoft-managed + bot management |
| Cost | Per capacity unit + data | Per request + base hourly |
| Best for | Internal L7 workloads, B2B | Public global workloads |
Front Door's WAF filters at the edge, before traffic enters the region. App Gateway's WAF filters at the regional boundary. Use both for layered protection on public services.
5. Private Endpoints — removing PaaS from the public internet
The pattern: deploy a Private Endpoint to each PaaS resource; disable public access on the PaaS resource; configure private DNS zone so <account>.privatelink.<service> resolves to the private IP.
resource pe 'Microsoft.Network/privateEndpoints@2024-03-01' = {
name: 'pe-sql-prod'
location: location
properties: {
subnet: { id: peSubnetId }
privateLinkServiceConnections: [
{
name: 'sqlConnection'
properties: {
privateLinkServiceId: sqlServerId
groupIds: ['sqlServer']
}
}
]
}
}
resource pdz 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2024-06-01' = {
name: 'pdz-sql/vnet-link'
properties: { virtualNetwork: { id: vnetId }, registrationEnabled: false }
}[!IMPORTANT] Pair Private Endpoint with
publicNetworkAccess: Disabledon the PaaS resource. Otherwise the public endpoint remains an attack surface.
6. DDoS Network Protection — when it's worth the price
| Tier | When |
|---|---|
| Basic (free) | Default for all public IPs; absorbs common volumetric attacks |
| Network Protection (paid) | Tier-1 public workloads, financial / public-sector targets |
Network Protection is per-VNet, so consolidating public IPs in a small number of VNets reduces cost. Cost-protection credits are an underrated benefit — they reimburse scaling charges incurred during DDoS attacks.
7. Zero Trust translation to network controls
| Zero Trust principle | Network control |
|---|---|
| Verify explicitly | Conditional Access + MFA on every admin login |
| Use least privilege | NSGs deny-by-default; ASGs scope precisely |
| Assume breach | Private Endpoints + Firewall inspection; assume the perimeter will fail |
| Identity-aware micro-segmentation | Use Entra ID workload identity + Private Link |
// Detect inbound flows from non-allowlisted CIDRs to admin ports
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.NETWORK"
| where Category == "NetworkSecurityGroupFlowEvent"
| extend props = parse_json(flowLog_s)
| where destinationPort_s in ("22","3389","5985","5986") and direction_s == "Inbound"
| project TimeGenerated, sourceAddress_s, destinationAddress_s, destinationPort_s, action_s
| where action_s == "Allow"8. Hybrid security considerations
Hybrid connectivity introduces shared-trust models. Best practices:
| Concern | Solution |
|---|---|
| On-prem-to-Azure traffic inspection | Azure Firewall in hub; UDR force-through from VPN/ER |
| Cross-tenant connectivity | Private Link Service to publish; consumer creates PE |
| AD trust integration | Entra Domain Services or Entra ID hybrid; not raw on-prem AD pass-through |
Worked Examples
Easy — segment a web tier from a DB tier
Problem. A web VM scale set must talk to a DB on port 1433; no other ports. Recommend.
Solution. Create asg-web and asg-db ASGs; attach NICs accordingly. NSG rules: allow asg-web asg-db on TCP 1433; deny all other inbound to asg-db. Apply NSG at the DB subnet.
Medium — egress filtering for compliance
Problem. A regulated workload must inspect TLS traffic to the internet and block known malicious URLs. Recommend.
Solution. Deploy Azure Firewall Premium in the hub VNet with TLS inspection enabled and IDPS turned on. UDR on every spoke subnet routes $0.0.0.0/0$ to the firewall's private IP. Add URL filtering rules for malicious categories. Spokes use Private Endpoints for PaaS to avoid round-trips through the firewall for trusted Microsoft services.
Hard — public global API with full defence-in-depth
Problem. Tier-1 public API. Requirements: WAF at edge, regional WAF, DDoS protection, private backends, egress filtering, no admin RDP.
Solution. Stack: Front Door Premium (WAF, bot management, DDoS Premium-included) regional Application Gateway v$2$ WAF private backends with Private Endpoints to PaaS. Egress through Azure Firewall Premium (TLS inspection, IDPS). Admin via Azure Bastion. DDoS Network Protection on the VNet hosting public IPs. Defender for Cloud at Standard tier for posture management.
9. Service endpoints vs Private Endpoints
Both reduce PaaS exposure but differ in their isolation model:
| Feature | Service Endpoint | Private Endpoint |
|---|---|---|
| What it does | Adds VNet identity to the PaaS firewall | Brings PaaS onto a private IP in the VNet |
| Public endpoint still exists? | Yes (filtered) | Yes (disable separately) |
| Cross-region | Limited | Yes |
| On-prem access via ExpressRoute / VPN | No | Yes |
| Recommended for new workloads | No | Yes |
Service endpoints are legacy. Microsoft's recommendation for new workloads is Private Endpoint with publicNetworkAccess: Disabled. Service endpoints remain useful for low-cost, in-VNet-only constraints where private DNS adds operational overhead.
10. virtual network flow logs and Traffic Analytics
A network without observability is a black box. virtual network flow logs capture every allow/deny decision per NIC; Traffic Analytics aggregates them for visualisation.
| Capability | Tool |
|---|---|
| Per-flow allow/deny capture | virtual network flow logs Storage account |
| Visualisation and analysis | Traffic Analytics (paid) |
| KQL query against flows | Log Analytics workspace |
| Alerting on suspicious patterns | Microsoft Sentinel rules |
# Enable virtual network flow logs via CLI
az network watcher flow-log create \
--location westeurope \
--resource-group rg-hub \
--name fl-prod \
--vnet vnet-prod \
--storage-account stnsglogs \
--enabled true \
--retention 30 \
--traffic-analytics true \
--workspace logana-hub[!TIP] Enable flow logs everywhere, even if Traffic Analytics is too expensive across the whole estate. Raw flow logs are cheap and become invaluable during incident response.
11. Identity-based perimeter — the modern frontier
Network controls protect against network-layer attacks, but most modern attacks combine network and identity vectors. The modern Zero Trust perimeter sits at identity — Entra ID, managed identities, Conditional Access. Combine network and identity layers:
| Layer | Network | Identity |
|---|---|---|
| Who | NSG / Firewall (by IP) | Conditional Access (by user / app / risk) |
| What | Port / protocol | Resource / API / claim |
| Verification | Stateful inspection | Token validation; MFA |
For tier-1 workloads, both must be tight. Some control planes (Microsoft Defender for Identity, Entra ID Protection) cross between network signals and identity signals to detect compromise patterns invisible from either side alone.
Visual Explanations
Figure 1 — Security architecture decision flow
Figure 2 — Hub-spoke with central firewall
Figure 3 — Quick chooser
| Need | Service |
|---|---|
| Segment subnets | NSG + ASG |
| Egress filtering | Azure Firewall |
| TLS inspection + IDPS | Azure Firewall Premium |
| Global L7 WAF | Front Door Premium |
| Regional L7 WAF | Application Gateway WAF v2 |
| DDoS Network protection | Azure DDoS Network Protection |
| Remove PaaS from internet | Private Endpoint + disable public access |
| Admin without public IPs | Bastion |
| Posture management | Defender for Cloud |
Figure 4 — WAF policy rule structure
A typical Front Door WAF policy combines managed rule sets, bot management, and custom rules:
| Layer | Purpose |
|---|---|
Managed: DefaultRuleSet (Microsoft_DefaultRuleSet_2.1) | Microsoft-maintained OWASP+ protections |
Managed: BotManagerRuleSet (Microsoft_BotManagerRuleSet_1.1) | Good / bad / unknown bot scoring |
| Custom: rate-limit by IP | Per-source throttling |
| Custom: geo-filter (deny / allow specific countries) | Compliance / sanctions list |
| Custom: header-based whitelist | Partner-API allowlist |
Set the WAF policy mode to Detection initially to log without blocking; review false positives over a one- to two-week observation window; flip to Prevention once the false-positive rate is acceptable. The exam tests the Detection Prevention progression.
Figure 5 — Private Endpoint DNS plumbing
Private Endpoints work end-to-end only when DNS resolves the public hostname to the private IP. The plumbing:
- Create the Private Endpoint a private IP appears in the VNet.
- Create / link a private DNS zone (e.g.,
privatelink.database.windows.net) to the VNet. - Add an A record in the zone mapping
<account>to the private IP. - On-prem clients: configure conditional forwarders to Azure DNS Private Resolver inbound endpoint.
resource pdz 'Microsoft.Network/privateDnsZones@2024-06-01' = {
name: 'privatelink.database.windows.net'
location: 'global'
}
resource link 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2024-06-01' = {
parent: pdz
name: 'link-vnet-hub'
location: 'global'
properties: { virtualNetwork: { id: vnetId }, registrationEnabled: false }
}Without the DNS plumbing in place, clients still resolve the public hostname through public DNS, even though they then send packets to a private IP address. The result varies: TLS errors at best, complete connection failure at worst.
12. Microsoft Defender for Cloud — posture, not just detection
Defender for Cloud has two layers:
| Layer | What it does |
|---|---|
| Free tier (always-on) | Recommends configuration improvements; Secure Score |
| Paid plans (per resource type) | Detection: Defender for Servers, for SQL, for Storage, for App Service, for Containers, for Key Vault, for Resource Manager, for DNS, for AI |
For network-security posture, the Secure Score captures NSG misconfigurations, public endpoints, missing WAF, missing DDoS — and drives the prioritised remediation backlog. Run it across all production subscriptions on a regular cadence and feed its recommendations back into the architecture roadmap.
13. JIT VM access — a complementary control
For VMs that must accept admin connections (despite Bastion being preferred), Just-In-Time VM Access (a Defender for Cloud feature) opens NSG rules on demand for a time-bound window. Operators request access; Azure opens RDP / SSH for, say, 3 hours; closes automatically. Combine with Bastion for the strongest pattern: most operators use Bastion for routine work; emergency-access via JIT for the rare cases that need direct NSG opens for diagnostics or vendor support.
Common Mistakes
❌ Myth: "Public endpoints with firewall rules are secure enough." ✅ Reality: Public endpoints are reachable from any internet host. Firewall rules at the PaaS resource limit what reaches it, but the resource is still discoverable. Private Endpoint removes it from the public network entirely.
❌ Myth: "NSGs at subnet are enough — no need for ASGs." ✅ Reality: NSGs by IP are brittle; IPs change. ASGs by role are stable and self-documenting. Use both.
❌ Myth: "DDoS Basic is enough." ✅ Reality: Basic absorbs common volumetric attacks. Network Protection adds adaptive tuning, alerts, cost protection — essentials for tier-1 public workloads.
❌ Myth: "TLS inspection breaks everything." ✅ Reality: TLS inspection breaks workloads with certificate pinning. For everything else, distribute the firewall's CA and inspect. Exempt the cert-pinning workloads via rules.
Practice Exercises
🟢 Exercise 1. Recommend a way to remove a SQL DB from the public internet.
▶✅ Solution
Deploy a Private Endpoint; set publicNetworkAccess: Disabled; configure private DNS zone for privatelink.database.windows.net.
🟡 Exercise 2. A workload needs OWASP rule enforcement at the global edge. Recommend.
▶✅ Solution
Front Door Premium with WAF policy in Prevention mode; enable OWASP $3.x$ rule set and bot management.
🟡 Exercise 3. A regulated workload needs egress IDPS and URL filtering. Recommend.
▶✅ Solution
Azure Firewall Premium with IDPS enabled and URL category-filtering rules. Hub-spoke with UDR force-through.
🔴 Exercise 4. A VM in subnet should never reach VMs in subnet , but the NSG isn't blocking traffic. Diagnose.
▶✅ Solution
Check NSG rule precedence — a higher-priority allow rule may override the deny. Also check NIC-level NSGs that may override subnet-level. Verify with virtual network flow logs.
🔴 Exercise 5. A team wants Private Endpoint but the PaaS resource still receives public traffic. Diagnose.
▶✅ Solution
publicNetworkAccess is still Enabled. Set to Disabled to fully isolate.
🟢 Exercise 6. True or false: Azure DDoS Basic protects every Azure public IP at no charge.
▶✅ Solution
True. Basic is always-on, no charge. Network Protection adds paid features.
🟡 Exercise 7. Sketch Bicep for an NSG rule referencing two ASGs.
▶✅ Solution
resource nsg 'Microsoft.Network/networkSecurityGroups@2024-03-01' = {
name: 'nsg-app'
location: location
properties: {
securityRules: [
{
name: 'AllowWebToApi'
properties: {
priority: 100
direction: 'Inbound'
access: 'Allow'
protocol: 'Tcp'
sourceApplicationSecurityGroups: [{ id: asgWeb.id }]
destinationApplicationSecurityGroups: [{ id: asgApi.id }]
destinationPortRange: '443'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
}
}
]
}
}Figure 6 — When Azure Firewall Basic is enough
Azure Firewall Basic is cheaper but limited. It supports L3/L4 filtering, threat intelligence-based filtering, and FQDN filtering only via the threat-intelligence path. It does not support TLS inspection or IDPS.
| Workload | Tier |
|---|---|
| Dev / test, small fleet | Basic |
| Most production with FQDN filtering | Standard |
| Regulated / TLS inspection / IDPS / URL filtering | Premium |
Basic's 250 Mbps throughput cap makes it unsuitable for any meaningful production workload. Use Basic only for dev/test scenarios where the cost matters more than the security feature set and the throughput cap is acceptable.
Figure 7 — TLS inspection deployment considerations
TLS inspection on Azure Firewall Premium requires several pieces to work together correctly:
| Item | Detail |
|---|---|
| Intermediate CA certificate | Must be issued from a CA trusted by clients |
| CA stored in Key Vault | Firewall reads it via managed identity |
| Client distribution of root CA | Endpoints / managed workstations trust the inspecting CA |
| Exemption list | Cert-pinning apps and certain SaaS exempt from inspection |
| Encrypted SNI handling | TLS $1.3 ESNI / ECH causes inspection challenges |
The operational overhead of TLS inspection is significant — CA distribution, exemption lists, performance impact — but the security benefit is full visibility into outbound encrypted traffic for content inspection and IDPS pattern matching. Reserve for regulated workloads where the audit requirement justifies the complexity.
Summary & Concept Map
- Defence in depth: six layers — Edge (Front Door WAF + DDoS), Regional WAF (AppGW), Egress (Azure Firewall), Segmentation (NSG/ASG), PaaS (Private Endpoint), Admin (Bastion + PIM).
- NSGs use ASGs for readable, IP-decoupled rules.
- Azure Firewall Premium adds TLS inspection and IDPS for regulated workloads.
- Private Endpoint removes PaaS from the public internet — pair with
publicNetworkAccess: Disabled. - WAF on both Front Door and App Gateway for layered application-layer defence.
- DDoS Network Protection for tier-1 public workloads.
- Zero Trust translates to: verify identity, deny-by-default, assume breach, micro-segment.