Please note, there are couple of things going on here, and is a multi-step question. Let's take it step-by-step.
Firstly, there are similar fields for clientIP because:
-
clientIP_s
: This field is typically used in the FrontdoorAccessLog category. It captures the IP address of the client making the request to Azure Front Door -
clientIp_s
: This field is used in the FrontdoorWebApplicationFirewallLog category. It also captures the client's IP address but is specifically related to logs generated by the Web Application Firewall (WAF) associated with Azure Front Door
These fields help in tracking and analyzing the source of requests and any potential security threats. Now, depending on which license SKU of Azure Front door you are using, you'd see difference if you rin the followng queries.
Front Door
Diagnostic logs Category == "FrontdoorAccessLog" or Category == "FrontdoorWebApplicationFirewallLog“
Log field clientIp_s
for client IP info
Log field trackingReference_s
for all WAF + Access logs related to a single HTTP request
Front Door Premium
Diagnostic logs Category == "FrontDoorWebApplicationFirewallLog" or Category == "FrontDoorAccessLog“
Log field clientIP_s
for client IP info
Application Gateway
Diagnostic logs Category == "ApplicationGatewayAccessLog" or Category == "ApplicationGatewayFirewallLog“
Log field clientIp_s
for client IP info
So, the fact there is already another filter rule you applied that returns a 429 on field clientIp_s
might clash with your StackOverFlow example.
Here are options you can try
1. Make a case-insensitive query
Change your query to something like this:
AzureDiagnostics
| where tolower(clientIp_s) startswith "111.222."
| project clientIp_s, ruleName_s, action_s, httpStatusCode_s
| take 10
2. Create the custom rule on PowerShell
To modify your custom rule to match both clientIP_s
and clientIp_s
, you would need to add a match condition for each in your WAF policy rule.
Here’s an example of how you can do this using Azure PowerShell. Running these, will create your custom rule.
# Define match conditions for clientIP_s and clientIp_s
$clientIP = New-AzFrontDoorWafMatchConditionObject -MatchVariable clientIP_s -OperatorProperty IPMatch -MatchValue "111.222."
$clientIp = New-AzFrontDoorWafMatchConditionObject -MatchVariable clientIp_s -OperatorProperty IPMatch -MatchValue "111.222."
# Add these match conditions to your custom rule
$customRule = New-AzFrontDoorWafCustomRuleObject -Name "StackOverflowExample" -RuleType MatchRule -MatchCondition $clientIP,$clientIp -Action Block -Priority 1
You may also use Azure CLI (for instance in Linux) as:
# Define the WAF policy name and resource group
waf_policy_name="your-waf-policy-name"
resource_group="your-resource-group-name"
# Define the custom rule name and priority
custom_rule_name="StackOverflowExample"
priority=100
# Define the IP address prefix to block
ip_prefix="111.222."
# Create the match conditions for clientIP_s and clientIp_s
match_condition_clientIP="clientIP_s=IPMatch=$ip_prefix"
match_condition_clientIp="clientIp_s=IPMatch=$ip_prefix"
# Create the custom rule with the match conditions
az network front-door waf-policy rule create \
dockerfile
--policy-name $waf_policy_name \
--resource-group $resource_group \
--name $custom_rule_name \
--priority $priority \
--action Block \
--rule-type MatchRule \
--match-condition $match_condition_clientIP $match_condition_clientIp
I'd also suggest reading here:
Policy settings for Web Application Firewall in Azure Front Door
I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.