0Pricing
Cloud & IT Cert Prep · Lesson

Web Application Firewall on Front Door

Attach a WAF policy to your Front Door profile, enable managed rule sets for OWASP Top 10 protection, and create custom rules to block known malicious IPs.

Web Application Firewall on Front Door is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is a Web Application Firewall?

A Web Application Firewall (WAF) inspects HTTP/HTTPS requests at Layer 7 and blocks known attack patterns before they reach your application. Common attacks it prevents include SQL injection, cross-site scripting (XSS), remote file inclusion, and protocol anomalies. Without a WAF, attackers can exploit vulnerabilities in your application code even if your network is correctly locked down. Azure WAF integrates with both Azure Front Door and Azure Application Gateway.

WAF Policy Resource

In Azure, a WAF policy is a standalone resource that contains managed rule sets and custom rules. You create the policy, configure rules, then associate it with one or more Front Door endpoints or Application Gateway instances. This decoupled design means one WAF policy can protect multiple Front Door endpoints — a single change to the policy propagates to all associated endpoints automatically. WAF policies exist in a specific Azure region but when attached to Front Door, protection is applied globally at all PoPs.

# Create a WAF policy for Front Door
az network front-door waf-policy create \
  --name myWAFPolicy \
  --resource-group myRG \
  --sku Premium_AzureFrontDoor \
  --mode Prevention

Detection vs Prevention Mode

WAF policies operate in two modes. Detection mode inspects all requests and logs matches against rules but does not block any traffic — useful for initial deployment to understand what traffic your policy would block before enforcing it. Prevention mode both logs and actively blocks requests that match rule conditions. Best practice is to start in Detection mode, review the WAF logs for false positives, tune rules, then switch to Prevention mode once you are confident the policy is correct.

# Switch WAF policy to Prevention mode
az network front-door waf-policy update \
  --name myWAFPolicy \
  --resource-group myRG \
  --mode Prevention

Microsoft Default Rule Set

The Microsoft Default Rule Set (DRS) is a managed rule group maintained by Microsoft's security team. It contains rules detecting the OWASP Top 10 vulnerabilities plus bot signatures and credential-stuffing patterns. Microsoft continuously updates DRS with new rules in response to emerging threats — you do not need to write rules yourself. DRS versions are periodically released (e.g. DRS 2.1), and you can upgrade your WAF policy to a newer version during a maintenance window.

# Add the Microsoft Default Rule Set to your WAF policy
az network front-door waf-policy managed-rules add \
  --policy-name myWAFPolicy \
  --resource-group myRG \
  --type Microsoft_DefaultRuleSet \
  --version '2.1'

OWASP Rule Set

The OWASP Core Rule Set (CRS) is available on Application Gateway WAF and as part of the Verizon-tier CDN WAF. It contains over 200 rules covering the OWASP Top 10: injection attacks, broken authentication, sensitive data exposure, XML external entity attacks, and more. Each rule has an ID and group (e.g. REQUEST-942-APPLICATION-ATTACK-SQLI). You can disable individual rules by ID to suppress false positives without disabling the entire rule group.

Custom WAF Rules

Custom rules let you write specific allow/block conditions that managed rule sets do not cover. A custom rule consists of one or more match conditions (e.g. source IP, request URI, header value, query string) combined with an action (Allow, Block, Log, or Redirect). Custom rules are evaluated before managed rule sets and support priority ordering. A common use case: block specific countries, rate-limit aggressive crawlers, or whitelist a trusted monitoring IP bypassing WAF rules.

# Create a custom rule to block requests from a specific IP
az network front-door waf-policy rule create \
  --name BlockMaliciousIP \
  --policy-name myWAFPolicy \
  --resource-group myRG \
  --priority 100 \
  --action Block \
  --rule-type MatchRule \
  --match-condition remoteAddr IPMatch '1.2.3.4/32'

Rate Limiting

Rate limiting rules restrict the number of HTTP requests from a single client IP address within a time window (1 or 5 minutes). When the request count exceeds the threshold, the WAF returns HTTP 429 (Too Many Requests) to that client. Rate limiting is effective against brute-force login attacks, credential stuffing, and API abuse. You configure the request threshold and window as part of the custom rule definition in the WAF policy.

# Create a rate limit rule — max 100 requests per minute per IP
az network front-door waf-policy rule create \
  --name RateLimitLogin \
  --policy-name myWAFPolicy \
  --resource-group myRG \
  --priority 200 \
  --action Block \
  --rule-type RateLimitRule \
  --rate-limit-threshold 100 \
  --rate-limit-duration-in-minutes 1 \
  --match-condition requestUri Contains '/login'

Bot Protection Rule Set

The Bot Manager rule set (available in Front Door Premium) classifies incoming traffic as good bots (verified search engine crawlers), bad bots (known scanners, vulnerability probes), and unknown bots (unclassified automated traffic). You can configure the action per category — allow good bots, block bad bots, and log unknown bots. Without bot protection, automated scanners can generate enormous traffic loads that inflate your costs and mask real user traffic in analytics.

WAF Exclusions

Managed rule sets sometimes generate false positives — blocking legitimate requests because they happen to match a security rule pattern. For example, a CMS with rich text editing may send HTML in POST bodies that matches an XSS rule. WAF exclusions let you exclude specific request attributes (request headers, cookies, query string parameters, or request body fields) from rule evaluation, either globally or for a specific rule group or rule ID, without disabling the rule entirely.

Monitoring WAF with Logs

WAF generates two types of log entries in Azure Monitor: WAF logs (every request that matched a rule, whether blocked or logged) and access logs (all requests including those that passed without matching any rule). Send these logs to a Log Analytics workspace and use KQL to query blocked request trends, identify top attacked endpoints, or investigate a specific client IP. The WAF Insights workbook in the portal provides pre-built dashboards visualising these logs.

// KQL — top 10 WAF rule hits in the last 24h
AzureDiagnostics
| where Category == 'FrontDoorWebApplicationFirewallLog'
| where TimeGenerated > ago(24h)
| where action_s == 'Block'
| summarize HitCount = count() by ruleName_s
| top 10 by HitCount desc

Associating WAF Policy with Front Door

To activate WAF protection, you must associate the WAF policy with your Front Door security profile. In the portal, navigate to your Front Door profile, select Security policies, and add the WAF policy, specifying which domains it applies to. Alternatively, use the CLI to link the policy. Once associated, the WAF inspects all HTTP/HTTPS requests arriving at those Front Door domains before routing them to origin. You can associate one WAF policy per domain.

# Associate WAF policy with a Front Door security policy
az afd security-policy create \
  --profile-name myFrontDoor \
  --resource-group myRG \
  --security-policy-name mySecurityPolicy \
  --domains /subscriptions/<sub>/resourceGroups/myRG/providers/Microsoft.Cdn/profiles/myFrontDoor/customDomains/myDomain \
  --waf-policy /subscriptions/<sub>/resourceGroups/myRG/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/myWAFPolicy

Quick Check

Test your understanding of Microsoft Azure Fundamentals (AZ-900) concepts from this lesson.

Lesson Recap

In this lesson you learned: WAF policies contain managed rule sets (Microsoft DRS, OWASP) and custom rules that inspect HTTP traffic before it reaches your origin, Detection mode lets you tune rules before switching to Prevention mode, and rate limiting rules protect against brute-force and abuse. Next up we explore using Front Door's rules engine to optimise performance with redirects and security headers.

Frequently asked questions

Is the “Web Application Firewall on Front Door” lesson free?

Yes — the full text of “Web Application Firewall on Front Door” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.

What will I learn in “Web Application Firewall on Front Door”?

Attach a WAF policy to your Front Door profile, enable managed rule sets for OWASP Top 10 protection, and create custom rules to block known malicious IPs. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cloud & IT Cert Prep?

No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Web Application Firewall on Front Door” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cloud & IT Cert Prep lesson?

Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Azure CDN Profiles and Endpoints
  2. Azure Front Door: Global Load Balancing
  3. Web Application Firewall on Front Door
  4. Optimising Performance with CDN Rules
← Back to Cloud & IT Cert Prep