Scaling IP Blocklists on Azure WAF, and Why Azure Firewall Is the Wrong Home for Them

7 min read

Every team running a public web app eventually builds a blocklist. It starts with a handful of abusive IPs and grows into thousands of entries copied from threat feeds, incident tickets, and chat threads. At that point two questions come up: how many blocks can the WAF actually hold, and what happens to performance when the list gets big?

This post covers the documented limits, a strategy that scales, a pipeline for keeping the list under control, and a common detour: reaching for Azure Firewall when it can’t see the traffic you want to block.

The numbers below come from Microsoft’s documentation at the time of writing. Limits change, so confirm them on the official Azure subscription and service limits page before you design around them.

What the limits are

LimitValue
Custom rules per WAF policy100
IP address ranges per match condition600 (CRS 3.2 / DRS or newer); 540 on CRS 3.1 and older
Practical ceiling per policyAbout 60,000 ranges
Applies toApplication Gateway WAF and Front Door WAF alike

Four details matter in practice:

  • A CIDR block counts as one entry. A /24 costs the same as a single IP, which is why aggregation is the most effective thing you can do to a big list.
  • Ranges shouldn’t overlap. Microsoft support guidance is that address ranges across your custom rules need to be unique and non-overlapping, so deduplicate and collapse before you deploy.
  • There’s no reusable IP list object. Addresses are written inline into each rule’s match condition, so a large list has to be split across rules.
  • Extra match conditions don’t extend the list. Conditions inside a rule are ANDed, not ORed, so you can’t get around the 600 limit by adding a second IP condition to the same rule. You need more rules.

Will a big list hurt performance?

Microsoft doesn’t publish numbers for this, so treat what follows as reasoning, not a guarantee.

IP matching is a cheap comparison, and custom rules are evaluated before the managed rule set, so a blocked request is rejected before the expensive OWASP inspection runs. A large blocklist is generally lighter than the managed rules you’re already running. The real costs are operational: more rules mean slower policy deployments and a list that’s harder to reason about. If you plan to use most of the 100-rule capacity, test latency first.

The strategy: use the cheapest control for each job

The mistake is putting everything into IP rules. Match the control to the threat:

  1. Whole countries: one geo-match rule replaces thousands of CIDRs.
  2. Known-bad reputation traffic: turn on the managed bot protection rule set so Microsoft maintains the IP intelligence instead of you.
  3. Abusive but not permanently bad clients: use rate limiting instead of permanent blocks, which avoids stale entries. Rate limiting is available on both Front Door and Application Gateway WAF v2, with a caveat: thresholds aren’t enforced exactly. On Application Gateway each instance keeps its own counter, and on Front Door a low threshold can let a few requests through while counters sync. Start in Log mode, and don’t use it for fine-grained control.
  4. Specific IPs and ranges you’ve decided to block: IP match custom rules, managed through a pipeline.

Only the fourth layer is a list you have to maintain, so only that layer needs to be treated as code.

Keep the IP list clean and automated

Treat the blocklist the way you’d treat any other piece of production configuration:

  • Source of truth in Git: one row per entry, with the CIDR, the reason, an owner, and an expiry date.
  • A pipeline (Bicep, Terraform, or CLI) that aggregates adjacent ranges, removes duplicates, and splits the result into rules of around 500 ranges, leaving headroom below the 600 limit.
  • Deterministic assignment of entries to rules, so a small change touches one rule instead of reshuffling everything.
  • Scheduled pruning. Lists that only grow become the performance and operations problem, which is why every entry carries an expiry.
  • A staged rollout. Ship new or changed rules with the action set to Log, review what they’d have blocked, then flip to Block. (Switching the whole policy to Detection mode also works, but rule-level actions let you stage changes without relaxing the rest of a policy that’s already in Prevention.)
  • Block over Allow. An Allow rule ends evaluation and skips all other WAF inspection, so a broad one quietly turns the WAF off for everything it matches.

Here’s a sample of that pipeline. The input is a CSV (cidr,reason,owner,expires) and the output is a set of custom rules ready to be injected into the policy:

#!/usr/bin/env python3
"""Turn blocklist.csv into Application Gateway WAF custom rules (IPv4)."""
import csv, hashlib, ipaddress, json, os
from datetime import date

RULE_COUNT = 20        # fixed capacity plan; changing it reshuffles every rule
MAX_PER_RULE = 550     # headroom below the 600-range limit
BASE_PRIORITY = 20     # leave lower numbers free for geo and rate-limit rules
ACTION = os.environ.get("WAF_ACTION", "Log")   # promote to "Block" after review

today = date.today()
v4, v6 = [], []

with open("blocklist.csv", newline="") as f:
    for row in csv.DictReader(f):
        expires = row.get("expires", "").strip()
        if expires and date.fromisoformat(expires) < today:
            continue                           # expired entries drop out automatically
        net = ipaddress.ip_network(row["cidr"].strip(), strict=False)
        (v4 if net.version == 4 else v6).append(net)

# Merge adjacent ranges; drop duplicates and ranges already covered by larger ones
v4 = list(ipaddress.collapse_addresses(v4))
v6 = list(ipaddress.collapse_addresses(v6))

# Stable hash assignment: a changed entry only touches the rule it lands in
buckets = [[] for _ in range(RULE_COUNT)]
for net in v4:
    h = int(hashlib.sha256(str(net).encode()).hexdigest(), 16)
    buckets[h % RULE_COUNT].append(str(net))

too_big = [i for i, b in enumerate(buckets) if len(b) > MAX_PER_RULE]
if too_big:
    raise SystemExit(f"Rules {too_big} exceed {MAX_PER_RULE} ranges: prune or raise RULE_COUNT")

rules = [
    {
        "name": f"BlockList{i:02d}",
        "priority": BASE_PRIORITY + i,
        "ruleType": "MatchRule",
        "action": ACTION,
        "matchConditions": [{
            "matchVariables": [{"variableName": "RemoteAddr"}],
            "operator": "IPMatch",
            "negationConditon": False,        # (sic) this is the property's spelling in the ARM API
            "matchValues": sorted(b),
        }],
    }
    for i, b in enumerate(buckets) if b
]

json.dump(rules, open("blocklist-rules.json", "w"), indent=2)
json.dump([str(n) for n in v6], open("blocklist-ipv6-review.json", "w"), indent=2)
print(f"{len(v4)} IPv4 ranges in {len(rules)} rules; {len(v6)} IPv6 ranges held for review")

A few notes on the design. The hash bucketing gives you the stable assignment: adding or removing one range changes one rule instead of shifting every boundary the way “fill rule 1, then rule 2” would. The fixed RULE_COUNT is a deliberate capacity plan, and the overflow check turns “we hit the limit” into a failed pipeline run you can read, instead of a rejected deployment. IPv6 is split out for review because IPv6 match support differs by platform, so confirm what your WAF accepts before you promote those entries. And the output matches the Application Gateway rule shape. Front Door’s WAF schema is different (matchVariable rather than matchVariables, and negateCondition), and on Front Door you should check whether you want RemoteAddr or SocketAddr, since they behave differently when the client is behind a proxy.

The catch on Front Door: propagation time

One caution that changes how you design emergency response. Front Door is a global service, and policy changes have to reach every edge location. Microsoft’s WAF FAQ says most policy deployments finish in under 20 minutes. Microsoft support staff have since said in Q&A threads that single operations can take up to 20 minutes and back-to-back changes can stretch to around 40, and users report waits of up to 45. Plan for the long end of that range.

Application Gateway is a regional service and Microsoft doesn’t publish a figure for it, but in practice it applies changes faster. Measure it in your own environment rather than assuming.

The consequence: don’t build an emergency blocking process that depends on editing IP rules on Front Door. An attack that peaks and ends in twenty minutes is over before the rule lands. Three things help:

  • Deploy your rate limit rules before an incident. A rate limit rule that’s already in place reacts to a surge as it happens, without any policy change. (Changing one carries the same propagation delay, so tune beforehand.)
  • Put regional custom rules on an Application Gateway WAF closer to the workload. Microsoft’s own guidance positions Front Door as the first line of global protection and Application Gateway WAF as the place for region-specific rules close to the workload.
  • Keep a pre-approved, pre-tested path for emergency changes, and know how long it really takes.

The detour: adding Azure Firewall for the blocklist

Azure Firewall’s IP Groups look like a natural home for a big list. They’re reusable across firewalls, regions and subscriptions, a firewall policy can reference up to 600 of them, each group holds up to 5,000 addresses or prefixes, and up to 20 groups can be updated in a single operation. An older Microsoft case study describes an automated pattern that updates groups instead of recreating rules, so there’s no gap in blocking, and reports that the networking team tested groups up to 5,000 addresses.

The problem is not capacity. It’s client IP visibility.

When Azure Firewall applies DNAT to inbound traffic, it also applies SNAT. The firewall itself sees the real client at its public endpoint, but whatever sits behind it sees the firewall’s address as the source. Microsoft’s architecture guidance is blunt about this: if the application needs the client IP, terminate the connection upstream in a layer 7 proxy such as Application Gateway or Front Door, which carries the client IP forward in the X-Forwarded-For header.

That shapes every option for combining the two services:

DesignWhat sees the real client IPVerdict for a client blocklist
Front Door at the edge, firewall behind itFront Door WAF. The firewall only sees Front Door.Keep client blocklists in Front Door WAF. Use the firewall for origin lockdown.
Application Gateway in parallel with the firewallThe gateway’s WAF, for web traffic. The firewall handles other workloads and outbound traffic.Keep the blocklist in the gateway’s WAF.
Application Gateway in front of the firewallThe WAF sees clients. The firewall sees the gateway’s IP.A client-IP deny list on the firewall is useless.
Firewall in front of the web app or gatewayThe firewall. Everything behind it sees the firewall’s address.Avoid this if the WAF behind it needs client IP rules.

So the firewall’s bulk IP blocking is mostly useful for non-HTTP traffic. It’s not where the web blocklist belongs.

The recommended layering

  1. Geo-match rules and managed bot protection at the WAF.
  2. Rate limiting at the WAF, deployed ahead of incidents and tuned in Log mode.
  3. A small, aggregated, pipeline-managed IP rule set in the WAF, where client IPs are visible.
  4. Origin lockdown, so your backend only accepts traffic from the WAF layer in front of it.

On that last one, Azure Firewall earns its place. With Front Door in front, restrict the firewall’s DNAT listener to Front Door’s backend IP ranges (published under the AzureFrontDoor.Backend service tag). Those ranges are shared by every Front Door customer, so Microsoft’s origin guidance pairs them with a check on the X-Azure-FDID header, which identifies your specific Front Door instance. Front Door Premium also supports Private Link to origins, which removes the public path entirely. The same principle applies with Application Gateway: the backend subnet should accept traffic only from the gateway.

If you ever outgrow the WAF’s roughly 60,000-range ceiling, treat it as an architecture decision, such as a different edge layer or a reputation service, and not a quick fix with the firewall.

The takeaway

Most teams don’t need to scale the blocklist. They need to shrink it: aggregate, expire, and replace long tails with geo and behavioral controls. Keep what remains in the WAF where client IPs are visible, manage it as code with expiry dates, stage every change through Log before Block, and use Azure Firewall for what it’s good at, which is protecting the origin and handling non-web traffic.


Discover more from ksharp

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from ksharp

Subscribe now to keep reading and get access to the full archive.

Continue reading