Web Application Firewall
Application Gateway vs Front Door WAF · detection and prevention · rule order and anomaly scoring · managed rule sets · policies and association · custom rules, rate limits, geo-filtering
By the tools4free.dev team · Last reviewed November 13, 2026
Practice questions for this topic →
Where WAF runs
Azure Web Application Firewall protects web applications from common exploits such as SQL injection and cross-site scripting. It deploys with Application Gateway, Application Gateway for Containers, Front Door and (in preview) Azure Content Delivery Network. It is in the network security category with Azure DDoS Protection and Azure Firewall.
| Item | Application Gateway WAF | Front Door WAF |
|---|---|---|
| Scope | Regional. Portal policy type: Regional WAF (Application Gateway). | Global, at Azure network edge locations. Portal policy type: Global WAF (Front Door). |
| Tier or SKU | WAF policy associations need WAF_v2 (WAF_v1 also exists). | Standard: custom rules only. Premium: full capabilities (managed rules, bot protection). Classic: older rule sets. |
| Managed rules based on | OWASP Core Rule Set (CRS 3.2, 3.1, 3.0) and Default Rule Set (DRS 2.2, 2.1). | Default Rule Set (DRS); DRS 2.0 and later use anomaly scoring. |
| Bot protection | Bot Manager rule set (WAF v2). | Bot Manager rule set; 1.1 on Premium. |
| Rule action types | ALLOW, BLOCK, LOG, plus anomaly score for the CRS. | Allow, Block, Log, Redirect, plus anomaly score (DRS 2.0 or later). |
| Policy attaches to | Application gateway (global), listener (per site) or path-based rule (per URI). | Front Door profile, domain or route. |
| Log name | ApplicationGatewayFirewallLog | FrontDoorWebApplicationFirewallLog (Standard/Premium) |
- An application gateway can host up to 40 websites that use a WAF.
- A Front Door WAF stops attacks close to the source, before they enter your virtual network. A policy is replicated to all Microsoft edge locations.
- Defender for Cloud scans for unprotected web applications and can recommend an Application Gateway WAF.
- WAF policies can be configured and managed at scale with Azure Firewall Manager.
- Use Azure DDoS Protection and a WAF together for web workloads.
Detection and prevention mode
| Detection | Prevention | |
|---|---|---|
| Behavior | Monitors and logs the request and the matched rule. No other action. | Takes the specified action when a rule matches, and logs it. |
| Default for a new policy | Yes (portal) | No: change it after tuning |
| Protection | None. Useful while you tune. | Blocks requests the rules detect. |
| Anomaly score of 5 or more (DRS 2.0+) | Logged, not blocked | Action set for the anomaly score (default Block) |
- Run a newly deployed WAF in detection mode for a short time in production. Review the firewall logs, add exclusions or custom rules, then switch to prevention.
- A policy must be enabled to inspect traffic. On Front Door a disabled policy pauses inspection and requests bypass the WAF.
- Front Door blocked requests return 403 with "The request is blocked." by default. You can set a custom status code (200, 403, 405, 406, 429) and message; it applies to all blocked requests. Application Gateway prevention mode returns 403 and closes the connection.
- The redirect URI for the Redirect action is a policy-level setting, required if any rule uses Redirect.
- A triggered custom rule is always logged in detection mode, whatever its action.
Rule order, actions and anomaly scoring
- Application Gateway and Front Door process custom rules before managed rule sets. (On Front Door, the HTTP DDoS ruleset is evaluated before custom rules and an Allow custom rule does not bypass it.)
- Rules run in priority order; a smaller number runs first and priorities are unique.
- When a rule matches, its action applies and lower-priority rules aren't processed. On Front Door custom rules, only Log lets evaluation continue.
- Managed rules with the anomaly score action add to a total. At 5 or more the WAF acts on the request.
| Rule severity | Anomaly score value |
|---|---|
| Critical | 5 |
| Error | 4 |
| Warning | 3 |
| Notice | 2 |
- A single Critical match reaches the threshold of 5 and blocks in prevention mode. One Warning (3) does not.
- Front Door DRS versions earlier than 2.0 are in traditional mode: a matching rule blocks the request.
- Allow: the request goes through and no lower-priority rule can block it. Log: log and continue. Redirect (Front Door): send to the policy's redirect URI.
- On Application Gateway, the Allow action applies only to the Bot Manager rule set, not to the CRS.
Managed rule sets and exclusions
| Topic | Rule |
|---|---|
| Default state | Managed rules are on by default in Detection mode. You can disable rules and set actions per rule. You can also remove the DRS from a policy. |
| Front Door DRS | Standard has custom rules only; managed rules need Premium (or Classic). DRS 2.0 and later use anomaly scoring. DRS 2.2 is based on OWASP CRS 3.3.4 and runs at paranoia level 1 by default. |
| Application Gateway | CRS 3.2, 3.1, 3.0 and DRS 2.2, 2.1. CRS 3.2 needs WAF_v2 and runs on the new WAF engine, so you can't downgrade to CRS 3.1 or earlier. Microsoft’s pages differ on the recommended version: most say to use the latest DRS (2.2), one Application Gateway bullet names 2.1, and the Front Door create page names DRS 2.1 as current for Premium. |
| Paranoia level | PL2 rules detect more but are expected to cause false positives. In DRS 2.2 they're disabled by default. PL3 and PL4 aren't supported in Azure WAF (CRS 3.2 PL3 and PL4 rules are always inactive). |
| Changing version | The portal resets rule state, actions and rule exclusions to the new version's defaults. Custom rules and policy settings aren't affected. Use PowerShell, CLI, REST or a template to keep overrides. Define WAF config as code. |
| Bot protection | Categories Bad, Good, Unknown. Front Door defaults: bad blocked, good allowed, unknown logged. On Application Gateway use it with any one OWASP rule set. Only one OWASP rule set at a time. |
| Microsoft Threat Intelligence rules | In DRS they replace some built-in rules, which become disabled. |
Exclusion lists
- An exclusion omits a request attribute (for example an authentication token in a header) from evaluation. The rest of the request is still inspected.
- Front Door exclusion scopes: rule set, rule group or single rule. Make exclusions as narrow as possible; use per-rule exclusions where you can.
- Front Door exclusions skip the field's value; the field name is still evaluated.
- Application Gateway per-rule exclusions need CRS 3.2 or later (or Bot Manager 1.0 or later). Selectors can't be regular expressions and XML request bodies aren't supported. Exclusions apply to the whole web application.
Policies and association
| Front Door | Application Gateway (WAF_v2) | |
|---|---|---|
| Scopes | Profile, domain, route | Gateway (global), listener (per site), path-based rule (per URI) |
| Most specific wins | Route over domain over profile | Per-URI over per-site over global |
| Other listeners/domains | Apply shared baseline controls at profile scope, then add domain- or route-level policies only where different controls are required | The gateway policy still applies to listeners without their own policy |
| Replace or remove | A domain already associated shows grayed out; remove it from the old association first | Assigning a policy to a gateway or listener that has one overwrites it. You can't disassociate a policy entirely. |
- Portal: Create a resource, search WAF, choose Web Application Firewall. Set Policy for (Regional WAF or Global WAF), then Association (Application Gateway, HTTP listener or Route path; or Front Door profile with scope Profile, Domain or Route).
- The WAF policy name must be unique.
- On Application Gateway a policy takes effect only once associated. There is no limit on the number of policies you create, and one policy can be associated with any combination of gateways, listeners and path rules.
- Old WAF config: a custom rules only policy can't be edited. Upgrade by creating a full WAF policy that copies every custom rule, exclusion and disabled rule, or set force mode to associate any policy.
Custom rules, rate limiting, geo-filtering and request limits
| Front Door | Application Gateway | |
|---|---|---|
| Rule types | Match rules and rate limit rules | MatchRule (rate limit rules need the new engine, CRS 3.2) |
| Priority | Unique integer | Unique, 1 to 100; up to 100 custom rules |
| Actions | Allow, Block, Log, Redirect | Allow, Block, Log |
| Conditions | Several per rule | Conditions in one rule are ANDed; use separate rules for OR |
| Geo | GeoMatch operator; include ZZ (unmapped IPs); max ten country/region codes per rule | Geomatch operator |
- Front Door rate limit: threshold per one-minute or five-minute window, counted per socket IP by default. Each edge location counts on its own. Grouping by country/region, ASN or JA4 is preview, Premium only.
- Application Gateway rate limit: sliding window. Group by client address (default), geography or none. Counters are per association; scaling out the gateway doesn't divide the threshold. Don't use it for fine-grained control.
- Gateway redirect rules bypass WAF custom rules. Custom rules can't allow or block by file name or file type.
- Application Gateway request size (CRS 3.2 or later): body inspection is on by default; inspection limit, body size enforcement and file upload enforcement can be changed independently. A 2 MB request body and 4 GB upload limit come with the new engine. There is a 4 KB buffer on the upload limit. Over-limit requests are blocked in prevention mode.
- A lower inspection limit can improve performance but lets uninspected content through.
CLI and PowerShell
| Task | Azure CLI | PowerShell |
|---|---|---|
| Show Application Gateway WAF policy settings | - | $plcy = Get-AzApplicationGatewayFirewallPolicy -Name <policy-name> -ResourceGroupName <resourcegroup-name>; $plcy.PolicySettings |
| Set request body inspection and size limits on an Application Gateway WAF policy | az network application-gateway waf-policy update --name <WAF Policy name> --resource-group <WAF policy RG> --set policySettings.request_body_inspect_limit_in_kb='128' policySettings.max_request_body_size_in_kb='128' policySettings.file_upload_limit_in_mb='100' --query policySettings -o table | $plcy.PolicySettings.RequestBodyEnforcement=false; Set-AzApplicationGatewayFirewallPolicy -InputObject $plcy |
| Put an Application Gateway WAF in force mode (associate any policy) | - | $appgw = Get-AzApplicationGateway -Name <your Application Gateway name> -ResourceGroupName <your Resource Group name>; $appgw.ForceFirewallPolicyAssociation = $true |
Exam Tips
Tick each tip once you can answer it without looking.
“A new WAF policy was created. What mode is it in, and what do you do next?” → Detection (logs only). Tune with logs and exclusions, then switch to Prevention.. Trap: Detection mode provides no protection; leaving it forever means no request is blocked.
“A WAF blocks a legitimate request that carries an authentication token in a header” → Add an exclusion for that attribute, as narrow as possible (per rule); the rest of the request is still inspected.. Trap: Disabling the whole rule set or the policy removes protection for everything else.
“Different WAF settings for each website behind one application gateway” → Per-site policies: associate a WAF policy with each listener (needs WAF_v2).. Trap: A gateway-level policy applies to all listeners that don't have their own policy.
“Two policies apply to one request: which wins?” → The most specific: Front Door route over domain over profile; Application Gateway per-URI over per-site over global.. Trap: The broader baseline policy does not override the narrower one.
“Front Door Standard profile needs managed rule sets and bot protection on its WAF” → Premium. Standard supports only custom rules.. Trap: Managed rules are supported only in Premium and Classic policies (Classic with older rule sets).
“Which rules run first, custom or managed?” → Custom rules, in ascending priority number; the first match with an action other than Log ends evaluation.. Trap: On Front Door the HTTP DDoS ruleset runs before custom rules and an Allow custom rule does not bypass it.
“Anomaly scoring: one Critical match versus one Warning match” → Critical = 5 reaches the threshold and blocks in prevention mode; Warning = 3 doesn't (Error 4, Notice 2).. Trap: In detection mode a score of 5 or more is only logged, not blocked.
“Policy state Disabled versus Detection mode on Front Door” → Disabled pauses inspection and requests bypass the WAF. Detection still evaluates and logs.. Trap: Detection mode doesn't block anything, but it still logs the matched rule.
“You change the managed rule set version in the portal and keep your tuning” → The portal resets rule state, actions and rule exclusions to defaults. Use PowerShell, CLI, REST or a template to keep them, or define config as code.. Trap: Custom rules and policy settings are not reset.
“Rate limit on Front Door” → Custom rate limit rule: threshold per 1 or 5 minutes, per socket IP by default, counted separately at each edge location.. Trap: Counts aren't aggregated globally; grouping by country, ASN or JA4 is preview and Premium only.
“Allow only customers from certain countries on Front Door” → Custom rule with GeoMatch; add the unknown code ZZ to avoid blocking unmapped IPs; at most ten codes per rule.. Trap: Forgetting ZZ can block valid users whose IPs aren't in the dataset.
“Application Gateway WAF needs rate limiting, per-rule exclusions and a 2 MB body limit” → CRS 3.2 or later (the new WAF engine); you can't downgrade from CRS 3.2 to 3.1.. Trap: CRS 3.1 and earlier run on the older engine without these features.
“What do clients see when the Front Door WAF blocks them by default?” → HTTP 403 with "The request is blocked."; a custom code (200, 403, 405, 406, 429) and message can be set at policy level.. Trap: A Redirect action needs a redirect URI defined in the policy settings.
“Remove the WAF policy from an application gateway” → Not supported. Once a policy is associated there must always be one; you can overwrite it.. Trap: Assigning a different policy to a listener overwrites its previous policy.
“Front Door WAF events aren't showing in Log Analytics” → Logs aren't enabled by default; enable diagnostic settings (FrontDoorWebApplicationFirewallLog).. Trap: Activity logs are on by default, but they record configuration changes, not WAF matches.
“Bot protection categories and Front Door defaults” → Bad, Good, Unknown. Bad blocked, good allowed, unknown logged.. Trap: Bot Manager 1.1 is available on Front Door Premium, not Standard.
“Application Gateway custom rule logic: block IP X or user agent Y” → Two separate rules. Conditions inside one rule are ANDed.. Trap: Priority must be unique, 1 to 100, and custom rules run before managed rules.
Sources
- Introduction to Azure Web Application Firewall
- What is Azure Web Application Firewall on Azure Front Door?
- What is Azure Web Application Firewall on Azure Application Gateway?
- Comparison between Azure Front Door and Azure Content Delivery Network (tiers)
- Front Door WAF DRS rule groups and rules
- Application Gateway WAF CRS and DRS rule groups and rules
- WAF policy overview (Application Gateway)
- Create WAF policies for Application Gateway
- Tutorial: Create a WAF policy for Azure Front Door - Azure portal
- Policy settings for WAF in Azure Front Door
- WAF exclusion lists in Azure Application Gateway
- WAF exclusion lists in Azure Front Door
- WAF custom rules for Azure Front Door
- WAF v2 custom rules on Application Gateway
- WAF request size limits in Azure Application Gateway
- WAF rate limiting for Azure Front Door
- Rate limiting on Application Gateway
- WAF on Application Gateway bot protection overview
- Best practices for WAF in Azure Front Door
- Best practices for WAF on Application Gateway
- WAF engine on Azure Application Gateway
- WAF monitoring and logging (Azure Front Door)
- Geo-filtering on a domain for Azure Front Door
Checked against Microsoft Learn on November 13, 2026.