Snippets
Snippet KQL : corréler WAF et APIM sur une API privée Azure
Une requête courte pour voir si une requête API privée est bloquée par Application Gateway WAF, reçue par APIM ou absente du chemin attendu.
Quand une API privée publiée via Application Gateway et APIM interne échoue, commence par vérifier où la requête apparaît. Cette requête rapproche les logs Application Gateway/WAF et APIM sur une même fenêtre.
let Window = 2h;
let Hostname = "api.internal.example.com";
let ApiPath = "/orders";
let Gateway =
AzureDiagnostics
| where TimeGenerated > ago(Window)
| where ResourceProvider == "MICROSOFT.NETWORK"
| where Category in ("ApplicationGatewayAccessLog", "ApplicationGatewayFirewallLog")
| where tostring(host_s) == Hostname or tostring(requestUri_s) has ApiPath
| project TimeGenerated,
Layer="application-gateway",
Action=tostring(action_s),
Status=tostring(httpStatus_d),
RuleId=tostring(ruleId_s),
Uri=tostring(requestUri_s),
ClientIp=tostring(clientIP_s),
CorrelationId=tostring(transactionId_g);
let Apim =
AzureDiagnostics
| where TimeGenerated > ago(Window)
| where ResourceProvider == "MICROSOFT.APIMANAGEMENT"
| where tostring(Url) has ApiPath or tostring(RequestUri) has ApiPath
| project TimeGenerated,
Layer="apim",
Action=tostring(OperationName),
Status=tostring(ResponseCode),
RuleId="",
Uri=tostring(Url),
ClientIp=tostring(CallerIPAddress),
CorrelationId=tostring(CorrelationId);
Gateway
| union Apim
| order by TimeGenerated desc Lecture rapide : Blocked côté gateway indique un sujet WAF ; présence gateway sans présence APIM oriente vers pool, probe, SNI ou host header ; présence APIM sans backend visible oriente vers policy, DNS privé, route ou identité.