Lesson 1 of 3 Event-Driven Workflows with Azure Event Grid

Understanding Azure Event Grid

This lesson explains events and event-driven design, topics, subscriptions and handlers, event schemas, delivery behaviour and how Event Grid differs from Service Bus.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish events from messages.
  • Describe system topics, custom topics and domains.
  • Compare the Event Grid and CloudEvents schemas.
  • Choose between Event Grid, Service Bus and Event Hubs.

Events and event-driven design

An event is a lightweight notification that something happened: a blob was created, a resource was deleted, an order was placed, a model training job finished. Unlike a message in a queue, an event is not a request to do something; the publisher does not know or care who reacts. This lets new behaviour be added by subscribing to existing events, without changing the publisher.

Azure Event Grid routes events from sources to handlers. It pushes each event to every matching subscription within seconds, retries failed deliveries, and scales to very high event rates with no infrastructure to manage. In AI solutions it typically starts ingestion when documents arrive, reacts to Key Vault secret expiry or App Configuration changes, and fans out application events to several consumers.

Sort into groups

Event or message?

Exam skills 3.1.2 · 3.1.1

Decide whether each item is an event for Event Grid or a message for Service Bus.

Log in to try this activity Interactive activities are free with an account.

Topics, subscriptions and handlers

Event Grid's model has three parts. A topic is an endpoint to which events are sent. An event subscription on a topic selects events, through filters, and names the handler to which they are delivered. Several subscriptions on one topic each receive their own copy of matching events.

  • System topics represent Azure services that publish events, such as Blob Storage, Key Vault, App Configuration, Azure Container Registry and resource groups. They are created for a source resource, often automatically when the first subscription is created.
  • Custom topics are created for applications that publish their own events.
  • Event domains group thousands of related topics, for example one per tenant, under one endpoint.
  • Partner topics receive events from third-party SaaS providers.

Handlers include Azure Functions (through the Event Grid trigger), webhooks (any HTTPS endpoint, such as an API in Container Apps), Service Bus queues and topics, Event Hubs, Storage queues and Azure Relay hybrid connections. Delivering into a Service Bus queue is a common way to combine Event Grid's push notification with a consumer-paced, reliable queue.

The following diagram shows the event path and the subscription's filters.

Reacting to new contracts with Event Grid. The storage account's system topic publishes BlobCreated events; an event subscription filters on the event type and on subjects that begin with the contracts container path and end with .pdf, and delivers to an Azure Functions Event Grid trigger that chunks and embeds the document.
A Service Bus queue can replace the function as the handler if processing must be paced.
Match the pairs

Kinds of topic

Exam skills 3.1.2

Match each kind of Event Grid topic with its use.

Log in to try this activity Interactive activities are free with an account.

Event schemas

Events are JSON objects in one of two schemas. A topic's input schema is set when it is created, and subscriptions can deliver in a chosen schema.

Field purposeEvent Grid schemaCloudEvents 1.0 schema
Unique identifieridid
What happenedeventTypetype
Where it came fromtopic (set by Event Grid)source
What it is aboutsubjectsubject
WheneventTimetime
Payloaddata and dataVersiondata and datacontenttype

CloudEvents is a Cloud Native Computing Foundation standard supported across clouds and tools, and is recommended for new custom topics. The subject field is important in both schemas because filters commonly match on it: for Blob Storage events it is a path such as /blobServices/default/containers/uploads/blobs/report.pdf. An event can be up to 1 MB, and it is billed in 64 KB increments.

Match the pairs

Two event schemas

Exam skills 3.1.2

Match each Event Grid schema field with its CloudEvents 1.0 equivalent.

Log in to try this activity Interactive activities are free with an account.

Delivery behaviour

Event Grid's basic delivery model is push: it sends each event to the handler as an HTTPS request and treats a 200 to 204 response as success. Delivery is at least once, so a handler can receive the same event twice and must be idempotent, and order is not guaranteed. Failed deliveries are retried on a schedule, and undeliverable events can be dead-lettered, as the last topic in this module explains.

Event Grid namespaces add a second model: namespace topics support pull delivery, in which consumers receive events, then acknowledge, release or reject them, much like a queue, as well as push delivery, and namespaces also host an MQTT broker for devices. Pull delivery suits consumers that must control their pace or cannot expose an endpoint.

Event Grid
CarriesNotifications that something happened
DeliveryPush to subscribers (pull in namespaces)
OrderingNot guaranteed
Typical AI useStart ingestion when a blob arrives
Choose when React to discrete events
Service Bus
CarriesCommands and work items
DeliveryConsumers pull at their own pace
OrderingFIFO with sessions
Typical AI useQueue embedding or inference jobs
Choose when Process work reliably and in order
Event Hubs
CarriesHigh-volume telemetry streams
DeliveryConsumers read partitions from an offset
OrderingPer partition
Typical AI useIngest clickstreams or device data for analysis
Choose when Stream millions of events per second
Scenario questions

Event Grid, Service Bus or Event Hubs?

Exam skills 3.1.2 · 3.1.1

Choose the Azure service that fits each workload.

Log in to try this activity Interactive activities are free with an account.
Worked example

Starting ingestion when documents arrive

Users upload contracts to a Blob Storage container named contracts. Each new PDF must be chunked and embedded. A nightly job currently lists the container to find new files, which delays search results by up to a day. The team wants processing within a minute and no polling.

A system topic for the storage account publishes Microsoft.Storage.BlobCreated events. An event subscription filters to that event type, to subjects beginning with /blobServices/default/containers/contracts/ and ending with .pdf, and delivers to an Azure Functions Event Grid trigger (or to a Service Bus queue if processing must be paced). The handler checks whether the blob was already processed, so a repeated event is harmless.

A timer that lists the container every minute is still polling and becomes expensive as the container grows. A Service Bus queue alone has no way to learn of new blobs. Event Hubs is designed for streams, not for reacting to individual blob events.

Check yourself

Why must Event Grid handlers be idempotent?

Show answer

Event Grid delivers at least once, so the same event can arrive more than once, and order is not guaranteed.

Exam Tips

Remember for the exam

  • Event Grid pushes notifications from topics to subscribed handlers; publishers do not know subscribers.
  • System topics for Azure services, custom topics for applications, domains for many related topics.
  • Delivery is at least once and unordered; handlers must be idempotent.
  • Event Grid for things that happened; Service Bus for work to do; Event Hubs for telemetry streams.