An attacker lists the keys of an Azure OpenAI or Microsoft Foundry resource, or uses a stolen key or token, to run paid models from outside your network. Some also deploy models, loosen content filters, or add connections and agents to a Foundry project. Rotate the keys and block key access first, because the Activity Log records key listing and deployment changes and never the model calls themselves.
Look here
Log
Search for
AzureActivity
Key listing, key regeneration and model changes on the account. The operations sit under Microsoft.CognitiveServices/accounts: listKeys/action, regenerateKey/action, write, deployments/write, raiPolicies/write, projects/write and connections/write. Query them by caller: AzureActivity | where OperationNameValue has "Microsoft.CognitiveServices/accounts" | project TimeGenerated, Caller, CallerIpAddress, OperationNameValue, _ResourceId
Platform metrics
Token and request volume per model deployment. Metrics need no setting and are kept 93 days, and they do not identify the client IP address or application: az monitor metrics list --resource <account-id> --metrics ProcessedPromptTokens GeneratedTokens AzureOpenAIRequests --dimension ModelDeploymentName --interval PT1H --aggregation Total --offset 7d
Request counts and results per operation. These categories stay off until you add a diagnostic setting on the account: AzureDiagnostics | where _ResourceId has "<account>" and Category == "RequestResponse" | summarize count() by OperationName, ResultSignature, bin(TimeGenerated, 1h)
ApiManagementGatewayLlmLog
Token counts per request, and prompts and completions if their collection is on. The table fills only when an API Management gateway fronts the models and large language model (LLM) logging is enabled. Messages over 32 KB are split into 32 KB chunks that share a CorrelationId
SecurityAlert
Defender alerts for AI workloads, which need the Defender for Cloud AI services plan: AI.Azure_DOWVolumeAnomaly, AI.Azure_AccessFromSuspiciousIP, AI.Azure_AccessFromAnonymizedIP, AI.Azure_CredentialTheftAttempt, AI.Azure_AnomalousToolInvocation and AI.Azure_Jailbreak.ContentFiltering.DetectedAttempt
Account settings
Whether key access is still on, shown as DisableLocalAuth: Get-AzCognitiveServicesAccount -ResourceGroupName <rg> -Name <account>
Deployments
Model deployments you did not create: az cognitiveservices account deployment list -g <rg> -n <account>
Cost Management
Cost by resource and meter for the account. Enterprise Agreement and Microsoft Customer Agreement data arrive in 8 to 24 hours, and pay-as-you-go data in up to 72 hours
Contain
#
Item
1
Save the account settings, the deployment list and the network rules as case evidence. List the network rules: az cognitiveservices account network-rule list -g <rg> -n <account>
Regenerate Key1 after the apps move to Key2: az cognitiveservices account keys regenerate --name <account> --resource-group <rg> --key-name Key1
4
Regenerate Key2 after the apps move to the new Key1: az cognitiveservices account keys regenerate --name <account> --resource-group <rg> --key-name Key2
5
Block key access for the account: Set-AzCognitiveServicesAccount -ResourceGroupName <rg> -Name <account> -DisableLocalAuth $true
6
Deny public networks except your ranges. Add every legitimate caller to the rule first: Update-AzCognitiveServicesAccountNetworkRuleSet -ResourceGroupName <rg> -Name <account> -DefaultAction Deny -IpRule @{IpAddressOrRange="<cidr>"}
7
Delete deployments the attacker created destructive, after recording: az cognitiveservices account deployment delete -g <rg> -n <account> --deployment-name <deployment>
Eradicate and recover
#
Item
1
Turn on resource logs for the account: az monitor diagnostic-settings create --name <name> --resource <account-id> --workspace <workspace-id> --logs "[{category:Audit,enabled:true},{category:RequestResponse,enabled:true},{category:AzureOpenAIRequestUsage,enabled:true}]"
2
Restore content filters changed through raiPolicies/write, and remove the projects, connections and agents the attacker added
3
Repeat the Activity Log search for listKeys/action by the same caller on every AI account in the tenant
4
Assign the Azure Policy "Azure AI Services resources should have key access disabled (disable local authentication)", and give apps the Cognitive Services OpenAI User role
5
Turn on the Defender for Cloud AI services plan for each subscription, and decide with the Legal advisor whether to enable user prompt evidence
6
Recover an account the attacker deleted. Recovery works within 48 hours of the delete: az cognitiveservices account recover --name <account> --resource-group <rg> --location <region>
Watch out
Disabling local authentication reaches the shared gateway after its cache refreshes. Microsoft says this usually takes a few minutes and can take several hours, so regenerate both keys as well.
Owner, Contributor and Cognitive Services Contributor can list and regenerate keys. Remove those roles from the attacker, or a new key leaks the same way.
Gateway LLM logs and Defender prompt evidence can contain customer prompts and model output. Limit who can read the workspace and record who opened them.
Cost data lags the usage by up to 72 hours. Use the token metrics for the live picture.
Microsoft Learn: Azure OpenAI monitoring data reference, supported logs and metrics for Microsoft.CognitiveServices/accounts, disable local authentication in Foundry Tools, AI services virtual networks, Azure OpenAI RBAC, recover or purge deleted Microsoft Foundry resources, AI + machine learning resource provider operations, API Management LLM logs, Cost Management data, platform metrics, activity log, Azure CLI and Az.CognitiveServices reference. Azure Policy built-in definitions repository. Checked October 2026. Defender for Cloud alerts for AI workloads and enable threat protection for AI services, where the plan toggle is still named AI services: checked October 2026.