Event Grid Core Concepts
Azure Event Grid has four fundamental building blocks: Events, Event Sources, Topics, and Event Subscriptions. Every Event Grid solution combines these four components. Understanding each one clearly is essential before building any real-world solution.
1. Event
An event is the smallest unit of information in Event Grid. It describes something that happened. An event does not carry large payloads or instructions — it simply announces a fact.
Every event follows a defined structure with standard fields.
Event Structure
| Field | Description | Example Value |
|---|---|---|
| id | Unique identifier for this event | "b6d521d3-9e8a-4bdf-a3c1" |
| topic | Full resource path of the event source | "/subscriptions/{subId}/resourceGroups/..." |
| subject | Publisher-defined path to the event subject | "/blobServices/default/containers/images/blobs/photo.jpg" |
| eventType | The type of event that occurred | "Microsoft.Storage.BlobCreated" |
| eventTime | When the event occurred in UTC | "2024-06-01T10:22:05.000Z" |
| data | Event-specific payload from the publisher | { "url": "https://...", "contentType": "image/jpeg" } |
| dataVersion | Schema version of the data object | "1.0" |
Example: BlobCreated Event
{
"id": "b6d521d3-9e8a-4bdf-a3c1-f78a901bc234",
"topic": "/subscriptions/abc123/resourceGroups/myRG/providers/Microsoft.Storage/storageAccounts/mystorage",
"subject": "/blobServices/default/containers/images/blobs/profile.jpg",
"eventType": "Microsoft.Storage.BlobCreated",
"eventTime": "2024-06-01T10:22:05.000Z",
"data": {
"url": "https://mystorage.blob.core.windows.net/images/profile.jpg",
"contentType": "image/jpeg",
"contentLength": 45678
},
"dataVersion": "1.0"
}
Events are published as arrays. Event Grid accepts up to 1 MB per batch. Each individual event must be under 1 MB in size. For most notification scenarios, events are much smaller — typically a few hundred bytes.
2. Event Source (Publisher)
An event source is any service or application that sends events to Event Grid. The source publishes events to a Topic. Event Grid does not pull events from sources — sources push events to Event Grid.
Built-in Azure Event Sources
| Azure Service | Example Events Published |
|---|---|
| Azure Blob Storage | BlobCreated, BlobDeleted |
| Azure Resource Manager | ResourceWriteSuccess, ResourceDeleteSuccess |
| Azure Container Registry | ImagePushed, ImageDeleted |
| Azure IoT Hub | DeviceCreated, DeviceDeleted, DeviceConnected |
| Azure Service Bus | ActiveMessagesAvailableWithNoListeners |
| Azure Key Vault | SecretNewVersionCreated, SecretExpired |
| Azure Maps | GeofenceEntered, GeofenceExited |
| Custom Application | Any custom event type defined by the developer |
3. Topic
A topic is an endpoint where event sources send their events. Think of a topic as a named mailbox. Publishers drop events into a mailbox. Subscribers open the mailbox and pick up events they care about.
A topic has a URL endpoint. Publishers send HTTP POST requests with event data to this URL. Event Grid then routes those events to all matching subscriptions.
Topic as a Mailbox – Diagram
+-------------------------+
Blob Storage | |
---- event --> | TOPIC ENDPOINT |
| (events.eastus. | ----> Subscription 1 --> Azure Function
Custom App | eventgrid.azure.net) |
---- event --> | | ----> Subscription 2 --> Logic App
+-------------------------+
----> Subscription 3 --> Webhook
Multiple publishers can send events to the same topic. Multiple subscribers can read from the same topic. Each subscriber gets its own copy of matching events.
Types of Topics
| Topic Type | Who Creates It | Example |
|---|---|---|
| System Topic | Azure creates automatically for Azure services | Topic for Blob Storage events |
| Custom Topic | Developer creates manually for custom apps | Topic for an e-commerce order system |
| Partner Topic | Third-party SaaS providers via Azure Partner program | Auth0 events, Salesforce events |
4. Event Subscription
An event subscription tells Event Grid which events a particular handler wants to receive and where to deliver them. Subscriptions sit between the topic and the event handler.
Each subscription defines three things:
- The topic – which topic to subscribe to
- Filters – which events to receive (by type, subject prefix, or custom attributes)
- The endpoint – where to deliver matching events (Azure Function, webhook URL, etc.)
Event Subscription Diagram
+----------------+ | TOPIC | | | | All Events: | | - OrderPlaced | +------------------------------+ | - OrderShipped| ---------> | SUBSCRIPTION 1 | | - UserCreated | | Filter: eventType=OrderPlaced| | - UserDeleted | | Handler: Azure Function | | | +------------------------------+ | | | | +------------------------------+ | | ---------> | SUBSCRIPTION 2 | | | | Filter: subject starts with | | | | /orders/premium | | | | Handler: Logic App | +----------------+ +------------------------------+
Filter Options in Event Subscription
| Filter Type | Description | Example |
|---|---|---|
| Event Type Filter | Match specific event types | Only receive "Microsoft.Storage.BlobCreated" |
| Subject Begins With | Match events where subject starts with a prefix | Subject starts with "/containers/images" |
| Subject Ends With | Match events where subject ends with a suffix | Subject ends with ".jpg" |
| Advanced Filters | Filter on any event data field with operators | data.size greater than 1000 |
5. Event Handler
An event handler is the service or endpoint that receives and processes the event. After Event Grid routes an event to a subscription endpoint, the handler runs the actual business logic.
Supported Event Handlers
| Handler Type | Best Use |
|---|---|
| Azure Functions | Serverless code execution triggered by events |
| Azure Logic Apps | Low-code workflows and integrations |
| Azure Event Hubs | Ingest events into a streaming pipeline |
| Azure Service Bus Queue/Topic | Reliable message delivery to applications |
| Azure Storage Queue | Lightweight queueing for background processing |
| Webhook (any HTTPS endpoint) | Any internet-accessible HTTP service |
| Azure Relay Hybrid Connections | Send events to applications inside a firewall |
How the Four Components Connect – End-to-End Flow
STEP 1: Event Occurs --> User uploads "report.pdf" to Azure Blob Storage STEP 2: Source Publishes Event to Topic --> Blob Storage sends BlobCreated event to System Topic endpoint STEP 3: Event Grid Evaluates Subscriptions --> Subscription 1: filter = subject ends with ".pdf" --> MATCH --> Subscription 2: filter = subject ends with ".jpg" --> NO MATCH STEP 4: Event Grid Delivers to Matched Handler --> Delivers event to Azure Function (Subscription 1) STEP 5: Handler Processes the Event --> Azure Function extracts text from the PDF --> Saves extracted content to Cosmos DB
Important Limits to Know
| Limit | Value |
|---|---|
| Maximum event size | 1 MB |
| Maximum batch size | 1 MB |
| Subscriptions per topic | 500 (default, can be increased) |
| Custom topics per subscription | 100 (default, can be increased) |
| Event retention (retry window) | Up to 24 hours |
| Advanced filter values per subscription | 25 |
Summary
The four core concepts of Azure Event Grid form a clean pipeline. An event source publishes events to a topic. Subscriptions with filters decide which events go where. Event handlers receive and process the matching events. This separation keeps each component independent and replaceable.
