Home / Azure

AzureCheat sheetAdvanced

Azure Blob Storage logs KQL cheat sheet - who deleted it, who gets 403s and who is hammering the account

Send blob resource logs to Log Analytics and query StorageBlobLogs to find deletes, 403s, throttling, shared-key and SAS users, and the clients that drive egress.

Deepak Bhardwaj7 min read

Applies toAzure Storage (general-purpose v2, Data Lake Storage), Azure Monitor resource logs, Log Analytics (StorageBlobLogs table)

When to use this

Someone asks "who deleted these blobs?", "why does the app get 403s?" or "can we disable shared key access yet?". Metrics won't tell you who made a request. Resource logs in the StorageBlobLogs table record every request, with the operation, status, auth type, caller identity, IP and user agent.

Data-plane operations (PutBlob, DeleteBlob, GetBlob) only appear in these logs. Control-plane changes, such as deleting the storage account or regenerating keys, go to the Activity Log instead.

Turn the logs on

Diagnostic settings for blob traffic sit on the blob service sub-resource, not on the storage account:

SA_ID=$(az storage account show -g rg-data -n stproddata01 --query id -o tsv)
LAW_ID=$(az monitor log-analytics workspace show -g rg-monitor -n law-prod --query id -o tsv)

az monitor diagnostic-settings create \
  --name blob-to-law \
  --resource "$SA_ID/blobServices/default" \
  --workspace "$LAW_ID" \
  --logs '[{"category":"StorageRead","enabled":true},{"category":"StorageWrite","enabled":true},{"category":"StorageDelete","enabled":true}]'

The same pattern works for fileServices/default, queueServices/default and tableServices/default, which write to StorageFileLogs, StorageQueueLogs and StorageTableLogs.

Warning

StorageRead on a busy account can produce more log volume than everything else in the workspace put together. Start with StorageWrite and StorageDelete. Turn on StorageRead for a limited time, or only on accounts where you need read auditing, and check ingestion with the Usage table after the first day.

Logs only cover requests made after the setting was created. Nothing is backfilled.

Columns you'll use most

Column Use
OperationName GetBlob, PutBlob, DeleteBlob, ListBlobs, DeleteContainer and so on
Category StorageRead, StorageWrite, StorageDelete
StatusCode, StatusText HTTP status and the storage error, for example AuthorizationPermissionMismatch
AuthenticationType How the caller signed in, for example OAuth, SAS, AccountKey, Anonymous
RequesterUpn, RequesterObjectId, RequesterAppId Entra identity, filled in for OAuth requests
CallerIpAddress Client IP, including the port
UserAgentHeader SDK, AzCopy, Storage Explorer, browser
ObjectKey /account/container/path/blob
DurationMs, ServerLatencyMs Total time compared with time spent inside the service
RequestBodySize, ResponseBodySize Bytes in and out

The exact values in AuthenticationType and StatusText can vary by API and version. Run summarize count() by AuthenticationType once to see what your accounts actually produce.

Who deleted it?

StorageBlobLogs
| where TimeGenerated > ago(7d)
| where AccountName == "stproddata01"
| where Category == "StorageDelete" or OperationName == "DeleteContainer"
| project TimeGenerated, OperationName, StatusCode, ObjectKey,
          AuthenticationType, RequesterUpn, RequesterObjectId, RequesterAppId,
          CallerIpAddress, UserAgentHeader
| order by TimeGenerated desc

If AuthenticationType shows AccountKey or SAS, the log has no identity. In that case, pivot on CallerIpAddress and UserAgentHeader, then match the IP to a VM, an App Service outbound address or a NAT gateway.

Bulk delete by one caller in a short window:

StorageBlobLogs
| where TimeGenerated > ago(24h)
| where Category == "StorageDelete" and StatusCode between (200 .. 299)
| summarize deletes = count(), first = min(TimeGenerated), last = max(TimeGenerated)
    by AccountName, RequesterUpn, RequesterAppId, CallerIpAddress, AuthenticationType
| where deletes > 100
| order by deletes desc

Caution

If the deletes are unexpected, stop the caller first: revoke its role assignment, rotate the key or revoke the SAS. Then recover. Soft delete and versioning only protect data within their retention period, so don't spend that time on analysis.

Why are requests getting 403?

StorageBlobLogs
| where TimeGenerated > ago(1h)
| where StatusCode == 403
| summarize failures = count(), sampleKey = any(ObjectKey)
    by AccountName, StatusText, AuthenticationType, RequesterUpn, RequesterAppId, CallerIpAddress
| order by failures desc
StatusText Likely cause Fix
AuthorizationPermissionMismatch OAuth caller lacks a data role Assign Storage Blob Data Reader or Contributor at the right scope
AuthorizationFailure Firewall or network rule blocked the caller Check network rules, trusted service exceptions and private endpoint DNS
AuthenticationFailed Bad signature, expired SAS, clock skew Regenerate the SAS and check the client clock
KeyBasedAuthenticationNotPermitted (name varies) Shared key is disabled on the account Move the caller to Entra ID

Can we disable shared key and SAS?

List every caller still using keys or account SAS before you set --allow-shared-key-access false:

StorageBlobLogs
| where TimeGenerated > ago(30d)
| where AuthenticationType in ("AccountKey", "SAS")
| summarize requests = count(), lastSeen = max(TimeGenerated),
            agents = make_set(UserAgentHeader, 5)
    by AccountName, AuthenticationType, CallerIp = tostring(split(CallerIpAddress, ":")[0])
| order by AccountName asc, requests desc

A user delegation SAS is signed with Entra credentials and keeps working when shared key is disabled. A service or account SAS is signed with the account key, so it stops working. Before you flip the setting, work out which kind each SAS caller uses.

az storage account update -g rg-data -n stproddata01 --allow-shared-key-access false

Warning

Some Azure services and older tools still authenticate with the account key. Watch the 30-day query until it returns nothing, or until every remaining caller has an owner and a migration date. Then disable shared key in a maintenance window, with a rollback ready (--allow-shared-key-access true).

Anonymous reads

StorageBlobLogs
| where TimeGenerated > ago(7d)
| where AuthenticationType == "Anonymous"
| summarize requests = count() by AccountName, container = tostring(split(ObjectKey, "/")[2])
| order by requests desc

If this returns rows you didn't expect, check which containers have public access and whether the account allows it (allowBlobPublicAccess).

Who is hammering the account?

Top callers by requests and egress:

StorageBlobLogs
| where TimeGenerated > ago(1h)
| summarize requests = count(), egressGB = round(sum(ResponseBodySize) / 1e9, 2)
    by AccountName, CallerIp = tostring(split(CallerIpAddress, ":")[0]),
       Identity = coalesce(RequesterUpn, RequesterAppId, AuthenticationType), UserAgentHeader
| top 20 by requests

Throttling and server errors over time:

StorageBlobLogs
| where TimeGenerated > ago(6h)
| where StatusCode in (500, 503)
| summarize count() by bin(TimeGenerated, 5m), StatusText, AccountName
| render timechart

Hot containers or prefixes, which often explain a partition hotspot:

StorageBlobLogs
| where TimeGenerated > ago(1h)
| extend parts = split(ObjectKey, "/")
| extend prefix = strcat(tostring(parts[2]), "/", tostring(parts[3]))
| summarize requests = count(), throttled = countif(StatusCode == 503) by AccountName, prefix
| top 20 by requests

Is it slow in storage or on the network?

StorageBlobLogs
| where TimeGenerated > ago(1h)
| where OperationName in ("GetBlob", "PutBlob", "PutBlock")
| extend clientSideMs = DurationMs - ServerLatencyMs
| summarize p95Total = percentile(DurationMs, 95),
            p95Server = percentile(ServerLatencyMs, 95),
            p95Client = percentile(clientSideMs, 95)
    by AccountName, OperationName, bin(TimeGenerated, 5m)

If p95Server is low and p95Total is high, the time is going to the network or a slow client reading the response, not to the storage service. Look at the client VM's size and network limits, its region and any NVA or firewall in the path.

Prevent it next time

  • Apply blob diagnostic settings through Azure Policy (deployIfNotExists) so every production account sends StorageWrite and StorageDelete to a central workspace.
  • Save the delete and bulk-delete queries as log alert rules on critical accounts.
  • Turn on soft delete for blobs and containers and enable versioning on accounts where accidental deletes would hurt.
  • Track AccountKey and SAS usage monthly and drive it to zero, then disable shared key access.
  • Keep CallerIpAddress meaningful by giving workloads stable outbound IPs (NAT gateway or private endpoints), so an IP maps to a known owner.