Azure Storage
Documentation

Blob Events

Azure Storage Blobs can emit events when specific operations occur, allowing you to build event-driven applications. These events are crucial for reacting to changes in your blob data without constant polling.

Supported Events

The following events can be published by Blob Storage:

Event Grid Integration

Azure Blob Storage integrates with Azure Event Grid, a fully managed event routing service. Event Grid simplifies building event-driven applications by enabling you to subscribe to events from various Azure sources, including Blob Storage.

How it works: When an event occurs in your storage account, Blob Storage publishes an event to Event Grid. Event Grid then delivers that event to your subscribed event handlers, such as Azure Functions, Azure Logic Apps, or custom webhooks.

Setting up Event Subscriptions

You can configure event subscriptions through the Azure portal, Azure CLI, or Azure PowerShell.

Example: Using Azure CLI

To create an event subscription for blob creation events:


az eventgrid event-subscription create \
  --resource-id "/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/" \
  --name "myBlobCreatedSubscription" \
  --topic-endpoint-type "webcallback" \
  --event-deliveries 10 \
  --event-filters "subjectbeginswith /blobServices/default/containers//blob" \
  --event-subscriptions "Microsoft.Storage.BlobCreated" \
  --endpoint ""
                

Replace placeholders like <YOUR_SUBSCRIPTION_ID>, <YOUR_RESOURCE_GROUP>, <YOUR_STORAGE_ACCOUNT_NAME>, <YOUR_CONTAINER_NAME>, and <YOUR_EVENT_HANDLER_ENDPOINT> with your specific values.

Event Schema

Events published by Blob Storage conform to the Event Grid event schema. A typical blob created event looks like this:


[
  {
    "topic": "/subscriptions/.../resourceGroups/.../providers/Microsoft.Storage/storageAccounts/...",
    "subject": "/blobServices/default/containers/mycontainer/blobs/myblob.txt",
    "eventType": "Microsoft.Storage.BlobCreated",
    "eventTime": "2023-10-27T10:30:00.1234567Z",
    "id": "...",
    "data": {
      "api": "PutBlob",
      "clientRequestId": "...",
      "requestId": "...",
      "contentType": "text/plain",
      "contentLength": 1024,
      "blobType": "BlockBlob",
      "url": "https://yourstorageaccount.blob.core.windows.net/mycontainer/myblob.txt",
      "sequencer": "...",
      "storageDiagnostics": {
        "batchId": "..."
      }
    },
    "metadataVersion": "1",
    "dataVersion": "1.0"
  }
]
                

Use Cases

Leveraging blob events opens up a wide range of possibilities:

By integrating with Azure Event Grid, you can build robust, scalable, and responsive applications that react intelligently to changes in your Azure Blob Storage.