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

FieldDescriptionExample Value
idUnique identifier for this event"b6d521d3-9e8a-4bdf-a3c1"
topicFull resource path of the event source"/subscriptions/{subId}/resourceGroups/..."
subjectPublisher-defined path to the event subject"/blobServices/default/containers/images/blobs/photo.jpg"
eventTypeThe type of event that occurred"Microsoft.Storage.BlobCreated"
eventTimeWhen the event occurred in UTC"2024-06-01T10:22:05.000Z"
dataEvent-specific payload from the publisher{ "url": "https://...", "contentType": "image/jpeg" }
dataVersionSchema 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 ServiceExample Events Published
Azure Blob StorageBlobCreated, BlobDeleted
Azure Resource ManagerResourceWriteSuccess, ResourceDeleteSuccess
Azure Container RegistryImagePushed, ImageDeleted
Azure IoT HubDeviceCreated, DeviceDeleted, DeviceConnected
Azure Service BusActiveMessagesAvailableWithNoListeners
Azure Key VaultSecretNewVersionCreated, SecretExpired
Azure MapsGeofenceEntered, GeofenceExited
Custom ApplicationAny 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 TypeWho Creates ItExample
System TopicAzure creates automatically for Azure servicesTopic for Blob Storage events
Custom TopicDeveloper creates manually for custom appsTopic for an e-commerce order system
Partner TopicThird-party SaaS providers via Azure Partner programAuth0 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:

  1. The topic – which topic to subscribe to
  2. Filters – which events to receive (by type, subject prefix, or custom attributes)
  3. 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 TypeDescriptionExample
Event Type FilterMatch specific event typesOnly receive "Microsoft.Storage.BlobCreated"
Subject Begins WithMatch events where subject starts with a prefixSubject starts with "/containers/images"
Subject Ends WithMatch events where subject ends with a suffixSubject ends with ".jpg"
Advanced FiltersFilter on any event data field with operatorsdata.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 TypeBest Use
Azure FunctionsServerless code execution triggered by events
Azure Logic AppsLow-code workflows and integrations
Azure Event HubsIngest events into a streaming pipeline
Azure Service Bus Queue/TopicReliable message delivery to applications
Azure Storage QueueLightweight queueing for background processing
Webhook (any HTTPS endpoint)Any internet-accessible HTTP service
Azure Relay Hybrid ConnectionsSend 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

LimitValue
Maximum event size1 MB
Maximum batch size1 MB
Subscriptions per topic500 (default, can be increased)
Custom topics per subscription100 (default, can be increased)
Event retention (retry window)Up to 24 hours
Advanced filter values per subscription25

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.

Leave a Comment