Security Web application firewall premium template-spec-upgraded field-manual-template-specs

Application Gateway WAF policy

An Application Gateway WAF policy is the rulebook that tells Application Gateway's Web Application Firewall how to inspect web requests. It can use Microsoft-managed rule sets, custom rules, exclusions, prevention or detection mode, and other settings. The policy can apply broadly to the gateway or more narrowly to a listener or path-based rule. For operators, it separates security tuning from gateway plumbing so teams can review what is blocked, allowed, excluded, or logged without rebuilding the whole gateway.

Aliases
Application Gateway WAF policy, WAF policy for Application Gateway, Azure WAF policy, regional WAF policy
Difficulty
intermediate
CLI mappings
4
Last verified
2026-06-02

Microsoft Learn

An Application Gateway WAF policy is an Azure Web Application Firewall policy that stores WAF settings for Application Gateway v2. Microsoft Learn explains that policies include managed rules, custom rules, exclusions, and policy settings, then take effect when associated to a gateway, listener, or path rule.

Microsoft Learn: Azure Web Application Firewall policy overview2026-06-02

Technical context

Technically, the WAF policy is a Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies resource associated with Application Gateway v2. It sits in the application edge security layer, not inside the application code. Managed rules inspect common attack patterns, custom rules add organization-specific conditions, exclusions reduce false positives, and policy settings control mode, request body handling, file limits, and logging behavior. The policy affects data-plane request evaluation only when it is attached to an Application Gateway, listener, or path rule that receives the traffic.

Why it matters

Application Gateway WAF policy matters because web protection is only useful when it is strong enough to stop attacks and precise enough not to block real customers. A policy in detection mode may produce logs without stopping malicious traffic; prevention mode can stop threats but also surface false positives. Custom rules, exclusions, and managed rule-set versions become production change items, not security decorations. The policy gives security and application teams a shared object to review during audits, incidents, and releases. Without disciplined WAF policy ownership, teams either leave applications underprotected or create emergency bypasses when legitimate users are blocked. Ownership matters.

Where you see it

Signals, screens, and Azure surfaces where this term usually becomes operational.

Signal 01

In the WAF policy blade, managed rule sets, custom rules, exclusions, mode, state, and policy associations show the active inspection behavior for traffic requests today.

Signal 02

In Application Gateway configuration, the policy appears globally, on a listener, or on a path rule, which determines its actual blast radius for users today.

Signal 03

In WAF diagnostic logs, rule IDs, actions, matched variables, request URIs, client IPs, policy names, and messages explain why a request was blocked or allowed.

When this becomes relevant

Specific situations where this term helps solve real Azure design, operations, migration, security, reliability, cost, or governance problems.

  • Move from WAF detection mode to prevention mode after reviewing false positives for critical user journeys.
  • Apply stricter rules to payment, login, or form paths without forcing the same policy on static content.
  • Add custom rules for abusive IP ranges, headers, geographies, methods, or bot-like request patterns.
  • Document and narrow exclusions when managed rules block valid application payloads or uploads.
  • Produce audit evidence showing which managed rule set, policy mode, and custom rules protect each web entry point.

Real-world case studies

Different enterprise-style examples that show the term being used to hit measurable objectives.

Case study 01

Enrollment form false-positive tuning

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

An online education provider enabled WAF prevention for a student enrollment form and immediately blocked valid applications containing international names and long essay responses.

Business/Technical Objectives
  • Restore valid enrollment submissions without disabling WAF globally.
  • Keep managed rule protection for login and payment paths.
  • Document every exclusion with owner and expiration date.
  • Reduce false-positive support tickets before peak enrollment week.
Solution Using Application Gateway WAF policy

Security and application engineers moved the Application Gateway WAF policy back to detection mode for the enrollment listener while leaving payment paths in prevention mode through a path-specific policy. They reviewed WAF logs to identify managed rule IDs, matched variables, and request fields causing the blocks. Instead of excluding entire rule groups, they created narrow exclusions for specific form fields and tested sample submissions from multiple countries. CLI exported the policy before and after tuning, and the final policy was promoted to prevention only after synthetic enrollment tests passed. A workbook tracked blocked requests by rule ID, path, and release version.

Results & Business Impact
  • False-positive enrollment blocks dropped from 9.4% to 0.4% in three days.
  • Payment and login paths stayed in prevention mode throughout the tuning work.
  • Each exclusion had a documented field, rule ID, owner, and 60-day review date.
  • Enrollment support tickets during peak week were 57% lower than the previous cycle.
Key Takeaway for Glossary Readers

Application Gateway WAF policy works best when exclusions are narrow, evidence-based, and scoped to the paths that actually need them.

Case study 02

Ticketing bot surge containment

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A performing-arts ticketing platform faced automated cart creation before a popular concert sale. The application team could not ship bot controls fast enough.

Business/Technical Objectives
  • Reduce abusive cart requests before they reached the application.
  • Keep legitimate customer checkout completion above normal thresholds.
  • Avoid broad IP blocks that would hurt shared mobile networks.
  • Give fraud analysts useful request evidence in near real time.
Solution Using Application Gateway WAF policy

The platform used an Application Gateway WAF policy with managed rules plus custom rules based on request headers, method, path, rate patterns, and suspicious user-agent combinations. The team started in detection mode during rehearsal traffic, then moved selected custom rules to block mode for the /cart and /hold paths only. Exclusions were not applied to checkout payment fields without fraud approval. WAF logs flowed to Log Analytics and Sentinel, where analysts tracked rule hits, client networks, hostnames, and request paths. Azure CLI captured custom-rule priority and policy mode before the sale so operations could roll back quickly if completion rates dropped.

Results & Business Impact
  • Abusive cart-creation requests reaching the app fell 76% during the first sale hour.
  • Checkout completion stayed within 1.5% of the previous clean sale baseline.
  • No broad carrier network blocks were required.
  • Fraud analysts received usable WAF evidence within 12 minutes instead of the prior next-day export.
Key Takeaway for Glossary Readers

Application Gateway WAF policy can absorb abusive web patterns quickly when custom rules are targeted and backed by live business metrics.

Case study 03

Insurance API audit enforcement

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

An insurance claims API used Application Gateway but had inconsistent WAF settings across regions. An audit found some gateways logged attacks without blocking them.

Business/Technical Objectives
  • Standardize WAF policy mode and managed rule set across regions.
  • Prove which listeners and paths were protected.
  • Remove undocumented exclusions from legacy deployments.
  • Create repeatable evidence for quarterly compliance reviews.
Solution Using Application Gateway WAF policy

The cloud governance team created a baseline Application Gateway WAF policy in infrastructure code and associated it with the claims API listeners in two regions. CLI scripts listed current policies, managed rule sets, custom rules, exclusions, and gateway associations, then produced a drift report. Legacy exclusions were narrowed or removed after application owners tested claim submission payloads. Detection mode was allowed only in nonproduction or temporary exceptions approved through a ticket. Diagnostic settings sent WAF logs to the central workspace, and a compliance workbook displayed policy mode, attached listeners, rule-set version, and recent blocked actions.

Results & Business Impact
  • All production claims listeners moved to prevention mode within three release windows.
  • Undocumented exclusions dropped from 18 to 4, each with an owner and review date.
  • Quarterly evidence preparation time fell from 14 hours to 90 minutes.
  • Regional policy drift alerts caught one unauthorized mode change within 20 minutes.
Key Takeaway for Glossary Readers

A WAF policy is not merely a security switch; it is an auditable control that must be associated, logged, and reviewed consistently.

Why use Azure CLI for this?

With ten years of Azure engineering experience, I use Azure CLI for Application Gateway WAF policy because WAF investigations require exact rule IDs, modes, exclusions, associations, and managed rule-set versions. CLI can export policy JSON before a tuning change, list custom rules, confirm whether detection or prevention mode is active, and show where the policy is attached. That evidence is essential when a payment path is blocked or an auditor asks which protections are enforced. CLI also supports controlled promotion from detection to prevention because engineers can compare policies across environments and attach the same reviewed configuration through automation. That matters.

CLI use cases

  • Export WAF policy configuration before tuning managed rules or exclusions.
  • List custom rules and policy settings to confirm the active enforcement mode.
  • Check Application Gateway associations to prove which listeners or paths the policy protects.

Before you run CLI

  • Confirm tenant, subscription, resource group, WAF policy name, gateway association, listener scope, and target environment.
  • Know whether the command only reads policy state or can change prevention mode, exclusions, or custom rules.
  • Collect recent WAF logs and business-impact reports before disabling rules or creating broad exclusions.

What output tells you

  • Policy settings show whether requests are logged only or actively blocked through prevention mode.
  • Managed and custom rule output shows which protections, overrides, priorities, and exclusions are currently configured.
  • Association output confirms whether the policy protects the intended gateway, listener, or path-based rule.

Mapped Azure CLI commands

Application Gateway WAF policy CLI commands

direct
az network application-gateway waf-policy show --name <waf-policy> --resource-group <resource-group>
az network application-gateway waf-policydiscoverSecurity
az network application-gateway waf-policy list --resource-group <resource-group> --output table
az network application-gateway waf-policydiscoverSecurity
az network application-gateway waf-policy custom-rule list --policy-name <waf-policy> --resource-group <resource-group>
az network application-gateway waf-policy custom-rulediscoverSecurity
az network application-gateway waf-policy managed-rules rule-set list
az network application-gateway waf-policy managed-rules rule-setdiscoverSecurity
az network application-gateway waf-policy policy-setting update --policy-name <waf-policy> --resource-group <resource-group> --mode Prevention
az network application-gateway waf-policy policy-settingsecureSecurity

Architecture context

Architecturally, an Application Gateway WAF policy belongs at the regional HTTP edge, usually alongside listener design, TLS termination, backend routing, and logging. A shared gateway may use a global policy for baseline protection while sensitive applications use listener-specific or path-specific policies. Architects decide which managed rule set version is standard, how custom rules handle bots or abusive patterns, and how exclusions are approved. The policy should be managed as code because a small exclusion can change security posture for multiple paths. It also needs observability through WAF logs, dashboards, and alert rules that distinguish real attacks from false positives. Ownership matters.

Security

Security impact is direct and high. The policy can block SQL injection, cross-site scripting, protocol anomalies, known malicious patterns, and custom conditions, depending on managed and custom rule configuration. Weak settings, broad exclusions, or permanent detection mode can leave applications exposed even though a WAF exists. Overly aggressive rules can force teams to bypass the gateway during incidents, which is also dangerous. Review policy changes with security and application owners, document rule exclusions, and scope policies carefully. Logs should capture rule ID, action, matched variable, client IP, hostname, and path so investigations do not rely on guesswork. Review changes carefully.

Cost

The policy affects cost through WAF-enabled Application Gateway SKUs, log volume, tuning effort, incident labor, and avoided breach impact. More detailed logging improves investigations but can increase Log Analytics ingestion and retention cost. Excessive false positives create support tickets and emergency engineering work. Duplicated policies across gateways can also increase governance overhead when every team tunes rules separately. On the other hand, a well-tuned policy can reduce fraud, scraping, and abuse before expensive backend processing occurs. FinOps and security reviews should look at WAF request volume, log retention, policy reuse, blocked abusive traffic, and the cost of manual exception handling.

Reliability

Reliability impact is real because WAF rules sit in the request path. A false positive can block checkout, enrollment, API uploads, or authentication even when the backend is healthy. Reliable rollout usually starts in detection mode, reviews WAF logs, tunes exclusions, tests important journeys, and then moves to prevention mode. Policy association matters too: applying a strict policy globally can break paths that were never tested. Keep an emergency rollback or mode-change process, but do not make bypass the normal fix. Monitor blocked-request rates, anomaly scores, custom-rule hits, 403 spikes, and user-completion metrics after every policy change. Test rollback drills.

Performance

Performance is affected by request inspection, managed rule evaluation, custom-rule complexity, request body inspection, file upload limits, and gateway capacity. The overhead is normally acceptable when capacity is planned, but policy changes should be load tested for high-volume APIs or upload-heavy paths. Broad custom rules that evaluate many variables on every request can increase processing work. False positives also hurt perceived performance because users retry blocked actions or contact support. Track WAF latency indicators with gateway capacity, backend latency, blocked counts, and request size patterns. Tune policies based on measured traffic, not assumptions copied from another application. Benchmark high-volume paths.

Operations

Operators manage WAF policy through rule-set reviews, custom rule updates, exclusions, mode changes, association audits, and log analysis. Daily work includes identifying false positives, documenting why an exclusion exists, comparing policies across environments, and confirming the policy is attached where expected. During incidents, operators correlate WAF logs with application errors, support reports, and release changes to decide whether to tune a rule, change a path-specific policy, or roll back. Strong teams keep policy configuration in source control, run detection-mode tests before enforcement, and require expiration or review dates for risky exclusions. Review exceptions monthly with security and application owners together.

Common mistakes

  • Leaving production in detection mode indefinitely while assuming malicious requests are being blocked.
  • Creating broad exclusions that silence false positives but also remove protection from sensitive fields.
  • Attaching one strict policy globally without testing every hostname and path that shares the gateway.