API Management diagnostic logs in Log Analytics are analyzed for LLM-related operations. Requests are grouped by caller IP, the number of distinct monitored actions (e.g., ChatCompletions_Create, ImageGenerations_Create) within a configurable minutes window is measured, and that ratio is compared to a threshold to surface anomalous multi-action patterns.
Risk
Concentrated LLM activity from one IP indicates automation or leaked credentials.
- Availability/cost: rapid token burn and quota exhaustion
- Confidentiality: exposure of prompts/completions and model details
- Integrity: abuse of deployment/model actions enabling unauthorized changes or mass content generation
Run this check with Prowler CLI
prowler azure --checks apim_threat_detection_llm_jacking
Recommendation
Adopt defense in depth for LLM APIs:
- Enforce least privilege; isolate management from inference
- Prefer managed identities over keys; rotate secrets
- Apply quotas, rate limiting, and IP allowlisting; use private access
- Alert on anomalous action diversity; review logs
Tune threshold and minutes for your environment.
Remediation
Native IaC
Terraform
Other
- In the Azure portal, open your API Management instance
- Go to APIs > All APIs
- Click Policies (Inbound processing)
- Add a when block to block the offending IP:
- Condition: @(context.Request.IpAddress == "<OFFENDING_IP>")
- Action: return-response with status 403 Forbidden
- Save the policy
- Re-run the scan after the detection window elapses to confirm PASS
Source Code
Resource Type
microsoft.apimanagement/service