Azure Event Grid: Telling Your Systems What Just Happened
A complete, plain-English guide to Event Grid: events, topics, subscriptions, handlers, schemas, filtering, delivery and retries, dead-lettering, namespaces with MQTT and pull delivery, security, monitoring, cost, and how it fits beside Service Bus and Event Hubs.
Imagine a large office building with a front desk. Whenever something happens, a delivery arrives, a visitor signs in, a fire alarm test begins, the desk does not phone every department one by one. Instead, it rings a bell and announces the news on a notice board, and every department that has asked to hear about that kind of news is told immediately. Nobody has to keep walking to the desk asking, “Anything new?” Azure Event Grid is that announcement system for the cloud.
This guide assumes you know nothing about event-driven systems. Every new term is explained the first time it appears, with an everyday comparison. We then go deep: what an event is, how events travel from sources to handlers, how to choose and filter what you receive, how delivery, retries and failures are handled, how security works, how the newer namespace features such as MQTT and pull delivery fit in, and how to keep cost and complexity under control. Event Grid has grown into several related offerings, and details such as schemas, limits and prices change, so where details may have moved we say so and ask you to confirm with the official documentation before designing anything new.
1Why Events Matter and What Event Grid Is
Many systems waste effort asking “has anything changed?” over and over. Events turn that around.
Polling versus being told
The simplest way for one system to learn about changes in another is polling: ask every few seconds, “Is there anything new?” Polling is wasteful, because most answers are “no”, and slow, because a change is noticed only at the next question. It also couples systems tightly, since the asker must know where to look and how often.
An event-driven design reverses the flow. When something happens, the system where it happened publishes a small message called an event: a short, factual statement that something occurred, such as “a file was uploaded” or “an order was placed”. Other systems that care subscribe and are told right away. The sender does not need to know who is listening, how many listeners there are, or what they will do.
Polling is walking to the post office every hour to check whether a parcel has arrived. Events are the postman ringing your doorbell the moment it comes. You save the walks, you learn sooner, and the post office does not need to know your daily routine.
What Event Grid does
Azure Event Grid is a fully managed service for routing events from sources to handlers. It receives events from Azure services, from your own applications, and from partner services, and delivers them to the places that asked for them, with filtering, retries and dead-lettering built in. It scales automatically and you pay for what you use, with no servers to run.
Reactive by design
Systems respond within moments of something happening instead of waiting for the next scheduled check.
Loose coupling
Publishers and handlers know nothing about each other. You can add or remove handlers without touching the source.
Built-in Azure sources
Many Azure services announce their own events, such as a file landing in storage, with no code on the sending side.
Managed reliability
Retries, backoff and dead-lettering are part of the service, so you do not build them yourself.
Event Grid has been evolving, with a newer namespace-based offering adding MQTT messaging and pull delivery alongside the original push-based service. This guide was written from memory without a live search. Before building, confirm features, regional availability, quotas and pricing on the official Azure documentation.
2The Core Vocabulary
Six words explain almost everything in Event Grid.
| Term | Meaning | Everyday comparison |
|---|---|---|
| Event | A small record saying that something happened, with details about it | A line on the notice board: “Parcel arrived at 10:02” |
| Event source | The system where the event happened | The front desk or the delivery door |
| Topic | The endpoint where a source sends events; the category board | The “Deliveries” board |
| Event subscription | An instruction saying which events to send where | A department’s request: “Tell me about deliveries for floor three” |
| Event handler | The place that receives the event and acts on it | The department that reacts |
| Event schema | The agreed shape of an event message | The standard form for notices |
flowchart LR
S["Event source"] -->|Publishes events| T["Topic"]
T --> SUB1["Subscription A with filter"]
T --> SUB2["Subscription B with filter"]
T --> SUB3["Subscription C with filter"]
SUB1 --> H1["Handler: function"]
SUB2 --> H2["Handler: queue"]
SUB3 --> H3["Handler: webhook"]
What an event looks like
An event is mostly a labelled envelope with a few standard fields, plus a data section with details that depend on the event. Typical envelope fields identify the event, say what kind of event it is, name the subject it is about, record when it happened, and say what version of the schema it follows. The data section carries the specifics, such as the name and size of a file. Events are meant to be small and factual. They tell handlers that something happened and where to look, not necessarily everything about it.
A notice says “Invoice 2041 was approved at 10:05”, not the whole invoice with all its attachments. Anyone who needs the full invoice goes to the filing system and fetches it. Keeping notices short keeps the board readable and fast.
An event states a fact that already happened, so it is named in the past tense: “order placed”, “file created”. That differs from a command, which asks someone to do something, such as “ship this order”. Mixing the two makes designs confusing.
3Events Versus Messages: Choosing the Right Mental Model
Not every piece of data sent between systems is an event. The distinction decides which Azure service fits.
| Aspect | Event | Message |
|---|---|---|
| Purpose | Announces that something happened | Carries data or a command that must be processed |
| Sender’s expectation | None; the sender does not care what listeners do | Sender expects the work to be done |
| Number of listeners | Zero, one or many | Usually one processor per message |
| Ordering and workflow control | Usually loosely ordered | Often needs ordering, sessions and transactions |
| Typical Azure service | Event Grid | Service Bus |
| High-volume stream of telemetry | Not designed for it | Event Hubs is built for streams |
An event is a public announcement over the loudspeaker: “The cafeteria is open.” A message is a work order placed on one specific person’s desk: “Please repair this machine.” The announcement is for anyone interested; the work order must be done by someone and tracked.
Reactive programming and discrete events
Event Grid is built for discrete events: individual, separate happenings that someone may want to react to. Examples are a file added, a virtual machine created, a deployment finished, or an order placed. It is not built for continuous streams, such as a million sensor readings a second, where the interest lies in the flow as a whole. For streams, Event Hubs is the usual choice, and Event Grid can be combined with it when stream data needs to trigger discrete reactions.
Ask: does the sender care what happens next? If not, and many parties might react, use an event. If the sender needs the work done reliably by exactly one processor, use a message queue.
4Kinds of Topics: System, Custom, Partner and Domains
A topic is where events are sent. Which kind you use depends on who the source is.
System topics
Built-in topics for Azure services that publish their own events, such as storage, resource groups, subscriptions and many others. You create subscriptions on them; you do not publish to them yourself.
Custom topics
Topics you create for your own applications to publish events to, using a web address and credentials.
Partner topics
Topics through which a partner service, outside Azure, publishes events into your Azure environment, set up through a partner registration and authorization.
Event domains
A management container for very large numbers of topics, for example one per customer, under a single endpoint, with per-topic access control and subscriptions.
flowchart TD
A["Azure services such as Storage or Resource Manager"] --> ST["System topic"]
B["Your applications"] --> CT["Custom topic"]
C["Partner SaaS service"] --> PT["Partner topic"]
D["Multi-tenant application"] --> DM["Event domain with many topics"]
ST --> SUBS["Event subscriptions"]
CT --> SUBS
PT --> SUBS
DM --> SUBS
SUBS --> HAND["Handlers"]
System topics are the building’s own automatic boards, fed by the building’s sensors. Custom topics are boards your department puts up for its own news. Partner topics are boards where an outside company, such as the courier, can post. Domains are a whole wall of boards, one for each tenant, managed together.
When to use event domains
If you build a multi-tenant application where every customer needs a separate topic with its own access and subscriptions, creating thousands of individual topics would be hard to manage. An event domain gives you one endpoint to publish to, with the topic named inside each event, and lets you grant each customer rights only to its own topic. It is a good fit for software-as-a-service products that want to expose events to customers.
Creating one custom topic per event type out of habit. Usually one topic per publishing application or business area, with event types and subjects used for finer distinction, is simpler to operate and secure.
5Event Subscriptions: Who Gets What
A subscription connects a topic to a handler and says which events to deliver.
An event subscription belongs to a topic and defines three things: the filter that selects events, the destination where matching events are delivered, and the delivery rules such as retries, expiry and dead-lettering. Many subscriptions can exist on one topic, and each receives its own copy of every matching event. That is the fan-out behavior: one event, many independent reactions.
sequenceDiagram
participant SRC as Source
participant TOP as Topic
participant SUB as Subscription with filter
participant HAN as Handler
SRC->>TOP: Publish event
TOP->>SUB: Offer event to each subscription
SUB->>SUB: Check filter
SUB->>HAN: Deliver if matched
HAN-->>SUB: Success response
Note over SUB,HAN: If no success, retry later according to policy
Each department fills a request slip: “Send me notices about deliveries to floor three, to this desk, try again if I am away for up to a day, and put anything you cannot deliver in this tray.” The front desk keeps one slip per request and works through all of them for every notice.
Choose the topic
Pick the system, custom, partner or domain topic that carries the events you care about.
Choose the filter
Select event types, subject patterns or data conditions so you receive only relevant events.
Choose the destination
Select the handler and decide how Event Grid will authenticate to it.
Set the delivery rules
Configure retry duration, maximum attempts, expiration and a dead-letter location.
Validate and monitor
Confirm the destination accepts events, then watch delivery metrics and failures.
Give each handler its own subscription. Sharing one subscription between unrelated handlers means one slow or failing handler affects the others, and you cannot filter or tune them separately.
6Event Handlers: Where Events Land
Event Grid delivers to many kinds of destination. The right one depends on what must happen next.
| Handler | Best for | Watch out for |
|---|---|---|
| Azure Functions | Small pieces of code reacting to events, with automatic scaling | Make functions idempotent because duplicates can occur |
| Logic Apps | Low-code workflows with approvals and business connectors | Cost per action in busy flows |
| Webhook | Any web service, including your own applications and external tools | Must prove ownership during validation and respond quickly |
| Service Bus queue or topic | Buffering events for controlled, ordered or transactional processing | Adds another service to operate and pay for |
| Storage queue | Simple, low-cost buffering | Fewer advanced features than Service Bus |
| Event Hubs | Sending events into a streaming pipeline for analytics | Throughput planning on the Event Hubs side |
| Hybrid Connections | Reaching an application behind a firewall without opening inbound ports | Requires the relay listener to be running |
| Automation runbook through webhook | Operational actions on cloud and private resources | Protect the webhook address as a secret |
flowchart LR
E["Event: file uploaded"] --> G["Event Grid"]
G --> F["Function: scan the file"]
G --> L["Logic App: notify the team"]
G --> Q["Queue: buffer for batch processing"]
G --> H["Event Hub: feed analytics stream"]
Buffering with a queue
Sometimes the handler cannot keep up with bursts of events, or must process them carefully, one by one. A queue between Event Grid and the handler absorbs the burst: Event Grid delivers quickly to the queue, and the handler pulls work at its own pace. This is a very common and robust pattern, and it combines the broadcast strength of Event Grid with the control strength of Service Bus.
If the department can only handle five notices an hour, but fifty arrive at once, the front desk puts them in the department’s in-tray rather than shouting them all at once. The department works through the tray calmly.
Problem
A slow, fragile web service is subscribed directly to a very busy topic, with no buffer.
Why It’s Harmful
The service is overwhelmed, returns errors, and Event Grid backs off and retries, delaying all events for that subscription and eventually dead-lettering many of them.
Correct Approach
Deliver into a queue, and let the service consume at its own pace, or scale the handler to match the event rate.
7Event Schemas: Event Grid, CloudEvents and Custom Input
An agreed shape for events lets different systems understand each other.
Event Grid schema
The original Azure-specific shape, with fields for identifier, subject, event type, time, data and version. Used by many Azure system topics.
CloudEvents schema
An open industry standard from the Cloud Native Computing Foundation for describing events in a common way. Recommended for new designs where supported because it helps portability across clouds and tools.
Custom input schema
Lets you publish events in your own shape and map its fields to the standard fields, so existing applications can publish without reformatting.
Why a standard schema matters
If every team invents its own event format, every consumer must learn every format, and changing one breaks others. A standard envelope means tools, filters and monitoring work the same way for all events. The data section can still be specific to each event type. Treat the data shape as a public contract: version it, add fields rather than renaming or removing them, and document it where consumers can find it.
| Design choice | Advice |
|---|---|
| Event type naming | Use a consistent, dotted, namespaced form that includes the domain and the fact, in the past tense |
| Subject | Use a path-like value that identifies the thing the event is about, so that prefix and suffix filters work well |
| Data size | Keep events small; pass identifiers and links to large content, not the content itself |
| Versioning | Include a version and change by adding fields; publish a new event type for breaking changes |
| Sensitive data | Do not put secrets or unnecessary personal data in events; they pass through several systems and logs |
A standard notice form means every department can read every notice. If one department invents its own form, others cannot file or search it. Adding a new box to the form is fine; removing or renaming boxes breaks everyone’s filing cabinets.
Schema support differs between the classic service, system topics and the namespace offering. Confirm which schemas your chosen topic type supports before standardizing, and note that some Azure services publish only in the original Event Grid schema.
8Filtering: Receiving Only What You Need
Good filters save money, reduce load and keep handlers simple.
Event type filter
Choose which event types to receive, for example only “created” events and not “deleted” ones.
Subject filter
Match the beginning or end of the subject, such as everything under one folder path, or only files ending in a given extension. Can be made case-sensitive or not.
Advanced filter
Compare fields in the event, including inside the data section, with operators such as equals, one of a list, greater than, contains, starts with, or is null. Several conditions can be combined, within documented limits.
flowchart TD
EV["Incoming event"] --> T{"Event type matches?"}
T -->|No| DROP["Not delivered to this subscription"]
T -->|Yes| S{"Subject matches prefix and suffix?"}
S -->|No| DROP
S -->|Yes| A{"Advanced conditions satisfied?"}
A -->|No| DROP
A -->|Yes| DEL["Deliver to handler"]
Filter at the source of truth
Filter in the subscription rather than inside the handler whenever possible. Filtering in the subscription means unwanted events are never delivered, never billed as deliveries to that handler, never start a function, and never create noise in logs. It also makes the intent visible: anyone reading the subscription sees exactly which events trigger which reaction.
Only images in a folder
A storage subscription receives only “blob created” events whose subject begins with the uploads folder path and ends with an image extension, so the image-processing function runs only for images.
Only high-value orders
An advanced filter on an order amount field in the event data sends only large orders to a review workflow, while all orders go to the accounting queue.
Only production changes
A subscription on resource events filters on the subject to react only to changes in the production resource groups.
A good request slip says “only deliveries for floor three, only parcels, only urgent ones”. A poor slip says “tell me everything”, and the department spends its day reading notices it has no interest in.
Relying on filters for security. Filters decide what is delivered, but they are not a substitute for access control. Never assume a filter protects confidential events from a subscriber who has been given access to the topic.
9Delivery, Retries and Dead-Lettering
What happens when the handler is slow, busy or down?
Event Grid guarantees at-least-once delivery for the push model. That means that every event is delivered at least one time to every matching subscription, and in rare cases it may be delivered more than once. It does not promise ordering. Handlers must therefore be able to cope with duplicates and with events arriving in a different order than they happened.
The retry story
When a delivery attempt fails or the handler does not respond with a success code in time, Event Grid retries with increasing waits between attempts, a pattern called exponential backoff. By default it keeps trying for up to a day, for a limited number of attempts, and you can shorten both. Some failures are treated as permanent, for example when the destination does not exist or rejects the request as unauthorized, and are not retried in the same way. Slow or unhealthy endpoints may also have their deliveries delayed to protect them from being overwhelmed.
flowchart TD
A["Event matched"] --> B["Attempt delivery"]
B --> C{"Success response?"}
C -->|Yes| D["Done"]
C -->|No| E{"Retry window and attempts left?"}
E -->|Yes| F["Wait with increasing delay"]
F --> B
E -->|No| G{"Dead-letter configured?"}
G -->|Yes| H["Store event in blob storage with failure reason"]
G -->|No| I["Event is dropped"]
Dead-lettering
If delivery ultimately fails, the event can be saved in a storage container you choose, together with information about why it failed. This is called dead-lettering. Without it, such events are simply dropped. Enable dead-lettering on every subscription that matters, monitor the container, and create a procedure for examining and replaying events once the underlying problem is fixed.
If the department is out, the front desk tries again after a few minutes, then after an hour, then later still. If after a whole day nobody has collected the notice, it goes into a labelled “undelivered” tray with a note explaining what happened. Without the tray, it would be thrown away.
| Setting | Meaning | Advice |
|---|---|---|
| Event time to live | How long Event Grid keeps trying before giving up | Match to how long the event stays useful; stale events can be harmful |
| Maximum delivery attempts | Cap on attempts within the time window | Lower for time-sensitive events, higher for important ones |
| Dead-letter destination | Storage location for undelivered events | Always configure for important flows, with identity-based access |
| Batching | Delivering several events per request to a destination that supports it | Improves efficiency for high-volume flows; handlers must handle arrays |
Designing handlers for duplicates and disorder
Make handlers idempotent: processing the same event twice must have the same final effect as processing it once. A common approach is to record the identifier of each processed event, or to design operations as “set to this value” instead of “add one”. For disorder, do not assume that “created” arrives before “updated”. Use timestamps or version numbers in the data to decide whether an event is newer than what you already have.
Problem
A handler sends a customer email and charges a card each time it receives an “order placed” event, without checking whether that event was already processed.
Why It’s Harmful
Because delivery is at-least-once, a retry after a timeout can cause duplicate emails and double charges.
Correct Approach
Record processed event identifiers or use idempotency keys with downstream systems, so repeated events cause no extra effect.
10Endpoint Validation and Webhook Handshakes
Event Grid will not send events to an address until it is sure the owner agrees.
If anyone could point Event Grid at any web address, the service could be used to flood a stranger’s server. To prevent this, when you create a subscription to a webhook, Event Grid first sends a special validation event. The endpoint must prove it controls the address, either by echoing back a code included in the validation event or by visiting a validation address provided. Many Azure destinations, such as Functions with an Event Grid trigger, queues and Event Hubs, are validated automatically when you have rights to them.
sequenceDiagram
participant EG as Event Grid
participant WH as Webhook endpoint
EG->>WH: Send validation event with a code
WH-->>EG: Echo the code or confirm validation
EG->>EG: Mark subscription as validated
EG->>WH: Begin sending real events
Before the courier starts leaving packages at an address, they ring the bell once and ask, “Do you really live here and want my packages?” Only after you answer correctly do deliveries begin.
If your webhook is behind a gateway or firewall, make sure validation requests can reach it, and that the handler distinguishes validation events from real ones. A common failure at set-up is simply that the handshake request is blocked.
Validation methods and supported schemas for webhooks have changed over time, and the newer CloudEvents handshake differs from the original one. Check the current documentation for the exact handshake your chosen schema uses.
11Publishing Your Own Events
Besides Azure’s built-in events, your applications can announce their own.
To publish to a custom topic or domain, an application sends events to the topic’s web address over a secure connection, authenticating either with an access key, a shared access signature or, preferably, a Microsoft Entra identity that has been granted a data sender role on the topic. Events can be sent in batches to improve efficiency. The publisher gets a success response once Event Grid has accepted the events, which means the events are stored and will be delivered; it does not mean any handler has finished.
Decide what is worth announcing
Choose facts that others might care about, such as state changes in your business domain.
Define the event types and data
Agree on names, subjects and data fields, and document them as a contract.
Create the topic and grant sender rights
Use a managed identity or application identity with only the sender role.
Publish after the change is committed
Make sure the event is sent only once the underlying change is safely stored, so listeners never react to something that did not really happen.
Handle publish failures
Retry on temporary errors and have a plan if the topic is unreachable, so events are not silently lost.
A department that announces “Contract signed” should do so after the contract is really signed and filed, not before. Otherwise others act on news that turns out to be false.
The outbox idea
A subtle problem arises when an application must both save data in its database and publish an event. If it saves and then crashes before publishing, the event is lost. If it publishes and then fails to save, listeners react to something that never happened. A well-known solution is the outbox pattern: the application writes the event into a table in the same database transaction as the business change, and a separate small process reads that table and publishes the events, marking them as sent. This gives reliable publishing, and combined with idempotent handlers it gives dependable end-to-end behavior.
flowchart LR
APP["Application"] -->|One transaction| DB["Database: business data plus outbox table"]
DB --> REL["Relay process reads unsent events"]
REL -->|Publish| EG["Event Grid topic"]
REL -->|Mark as sent| DB
Not every system needs the outbox. For low-stakes announcements, publishing directly after the commit is acceptable. Use the outbox where losing or duplicating an event has a real business cost.
12Event Grid Namespaces: MQTT Broker and Pull Delivery
A newer part of Event Grid broadens what it can do beyond classic push delivery.
Alongside the original topics, Event Grid offers a namespace, a container that hosts newer capabilities. Two stand out. First, an MQTT broker: MQTT is a lightweight messaging protocol widely used by devices and sensors, built around publishers and subscribers exchanging messages on named topics. The namespace can accept connections from many devices, route their messages to each other, and also route them onward to Azure handlers. Second, pull delivery: instead of Event Grid pushing events to a handler, the handler connects and pulls events from a namespace topic at its own pace, then acknowledges, releases or rejects each one.
MQTT broker
Supports device and application messaging using the MQTT protocol, with publish and subscribe, authentication using certificates or identity, and routing to other Azure services.
Pull delivery
Handlers fetch events when ready, control their own rate, and settle each event with an explicit outcome. Useful when the handler sits behind a firewall or needs flow control.
Push delivery from namespaces
Namespace topics can also push to some destinations, offering a path to the same style as classic topics where supported.
| Aspect | Push delivery | Pull delivery |
|---|---|---|
| Who starts the exchange | Event Grid calls the handler | The handler calls Event Grid |
| Handler must be reachable | Yes, from Event Grid | No; it only needs outbound access |
| Rate control | Event Grid adjusts with backoff | The handler decides how fast to fetch |
| Handling outcome | Success or failure response | Acknowledge, release or reject each event |
| Best for | Reactive code that scales automatically | Controlled, rate-limited or private consumers |
flowchart LR
D1["Device 1"] -->|MQTT publish| N["Event Grid namespace MQTT broker"]
D2["Device 2"] -->|MQTT publish| N
N -->|MQTT subscribe| APP["Control application"]
N -->|Route to namespace topic| NT["Namespace topic"]
NT -->|Pull| PROC["Processing service"]
Push delivery is the postman ringing your bell. Pull delivery is you collecting your mail from the post office box whenever you have time, and signing for each letter. The MQTT broker is a switchboard where many small devices, like intercoms, talk to each other and to the office through named channels.
The namespace features are newer and still evolving: supported protocol versions, client limits, routing options, tiers and pricing may change. Some earlier arrangements, such as running Event Grid on edge or Kubernetes environments, have also been changed or retired. Confirm what is currently supported before committing a design.
13Common Azure System Event Sources
Many Azure services announce events without any extra code from you.
| Source | Example events | Typical reaction |
|---|---|---|
| Blob Storage | File created, file deleted | Scan, resize, index or copy the file |
| Azure subscriptions and resource groups | Resource written, deleted or action completed | Enforce tagging, audit, notify, trigger governance runbooks |
| Container Registry | Image pushed or deleted | Start a deployment or a security scan |
| Key Vault | Secret or certificate near expiry, new version created | Rotate secrets, notify owners, restart dependent apps |
| IoT Hub | Device connected, disconnected, created | Track device lifecycle and raise alerts |
| Service Bus and Event Hubs | Messages available with no active listener, capture file created | Wake up processors only when work exists |
| App Service and Functions | App changed, restarted, plan scaled | Operational notifications |
| Machine Learning and other data services | Model registered, run completed | Start downstream pipelines |
| Maps, Communication Services and others | Geofence entered, message received | Business reactions in applications |
Secret expiry handled before an outage
Key Vault announces that a certificate is about to expire. A subscription starts a workflow that renews it, updates dependent applications and informs the owners, so expiry never causes a surprise outage.
Governance on every new resource
A subscription-level system topic announces new resources. A function checks the tags and location against company rules and either corrects them or opens a ticket.
These are the building’s own sensors: the door sensor, the smoke detector and the temperature gauge, all already wired to the notice board. You simply choose which notices to read.
The list of services that publish events and the event types they support keeps growing. Before assuming a service can notify you of a change, check the supported event sources page; if not available, an alternative is the service’s own activity log or diagnostic stream.
14Architecture Patterns with Event Grid
A few designs appear again and again.
Pattern 1: Fan-out reaction
One event, many independent reactions. A file upload triggers a virus scan, a thumbnail creator, a metadata indexer and an audit log entry, each through its own subscription. Adding a fifth reaction later requires no change to the uploader.
Pattern 2: Event-carried notification with fetch
The event is small and holds identifiers. Handlers who need more details call the source service to fetch them. This keeps events cheap and avoids sending stale or sensitive data around.
Pattern 3: Choreography
Services react to each other’s events without a central controller. Order service announces “order placed”; payment service reacts and announces “payment taken”; shipping service reacts and announces “parcel dispatched”. Each service knows only the events it consumes and produces. It is flexible, but the overall flow becomes harder to see, so document it and trace it.
Pattern 4: Orchestration with events as triggers
A workflow service coordinates a long process and uses events to start it or to wake it when something external happens. This gives visibility and control for processes with many steps, approvals and compensation.
Pattern 5: Buffered integration
Event Grid delivers into a queue so that downstream systems process at their own pace and failures are isolated.
flowchart LR
OS["Order service"] -->|Order placed| EG["Event Grid"]
EG --> PS["Payment service"]
EG --> INV["Inventory service"]
EG --> NOT["Notification service"]
PS -->|Payment taken| EG2["Event Grid"]
EG2 --> SH["Shipping service"]
EG2 --> NOT
| Pattern | Strength | Weakness |
|---|---|---|
| Fan-out | Easy to extend, decoupled | Many consumers can hide dependencies |
| Notification and fetch | Small events, fresh data | Extra call; source must stay available |
| Choreography | No central bottleneck, flexible teams | Hard to see the whole flow and to debug |
| Orchestration | Clear flow and error handling | Central coordinator to maintain |
| Buffered integration | Resilient, rate controlled | Extra service and cost |
Choreography is a group of dancers who each know their own steps and react to what others do. Orchestration is a conductor who tells each musician when to play. Small ensembles dance well; big symphonies need conductors.
15Event Grid, Service Bus and Event Hubs Compared
Three messaging services, three different jobs.
| Question | Event Grid | Service Bus | Event Hubs |
|---|---|---|---|
| Core idea | Announce discrete events to many subscribers | Reliable enterprise messaging between applications | Ingest huge streams of data |
| Typical data | “Something happened” notifications | Commands, orders, business messages | Telemetry, logs, clickstreams |
| Delivery style | Push to handlers, with pull available in namespaces | Consumer pulls from queues or subscriptions | Consumer reads partitions from a position |
| Ordering | Not guaranteed | Available with sessions | Ordered within a partition |
| Transactions and duplicates detection | Not offered in the same way | Available | Not typical |
| Retention | Short retry window and dead-letter | Messages kept until processed or expired | Time-based retention for replay |
| Scale pattern | Many events, many subscriptions | Moderate volume, rich features | Very high throughput |
Event Grid is the loudspeaker announcement. Service Bus is the registered mail service with tracking, signatures and proof of delivery. Event Hubs is the giant conveyor belt that carries a constant river of items to be sorted later.
They are often combined
Event Grid into Service Bus
A resource event is delivered into a Service Bus queue so a back-end process can handle it with ordering, locking and dead-lettering.
Event Hubs into Event Grid
When a capture file from a stream lands in storage, a storage event starts a batch analysis job.
Event Grid for the signal, Service Bus for the work
An “order placed” event informs many systems at once, while the actual fulfilment instruction goes through a queue to exactly one processor.
When unsure, ask three questions: Is it a notification or work to be done? How many listeners? Is it a rare happening or a continuous stream? The answers usually point to one of the three.
16Security: Identity, Keys and Network Control
Events can reveal what is going on inside your systems, and the right to publish them can cause actions. Both deserve protection.
Controlling who can publish and who can subscribe
Role-based access
Roles control who can manage topics, create subscriptions, and send events. Grant publishing rights only to the applications that must publish, using a data sender role.
Microsoft Entra authentication
Prefer identity-based publishing to access keys. Identities can be audited and revoked individually and need no shared secret.
Keys and shared access signatures
Possible, but a leaked key lets anyone publish. Rotate regularly, keep in a secret store, and consider disabling key-based access where policy allows.
Managed identity for delivery
Let Event Grid authenticate to handlers and dead-letter storage with a managed identity, so no secrets are stored in the subscription.
flowchart LR
PUB["Publisher with identity"] -->|Token over TLS| TOP["Topic with role assignment"]
TOP --> EG["Event Grid"]
EG -->|Managed identity| H1["Queue or function handler"]
EG -->|Managed identity| DL["Dead-letter storage"]
PUB2["Unknown caller"] -.->|Rejected| TOP
Network protection
By default topics and domains are reachable through public endpoints, protected by authentication and always encrypted in transit. For tighter control you can restrict access to selected address ranges, or use private endpoints so publishers inside your virtual network reach the topic over private addresses and public access is turned off. Delivery to handlers behind private networks needs separate planning: in some cases, trusted-service access or a queue as an intermediate handler can help, and pull delivery lets a private consumer fetch events with outbound connections only.
Protecting the data in events
Events pass through the service, logs, dead-letter storage and handlers. Keep them free of secrets and unnecessary personal data. Where sensitive details are needed, include only an identifier and let authorized handlers fetch the details from the source. Encrypt dead-letter storage, restrict who can read it, and set retention to match policy.
Only staff with a badge may post on the notice board, and notices should not display passwords or customers’ home addresses. If a sensitive detail is needed, the notice says “see file 2041”, and only people allowed to open that file can read it.
Problem
A single topic access key is embedded in several applications and shared across teams, and events contain customer personal details in full.
Why It’s Harmful
A leak of the key allows anyone to inject false events that trigger real actions, and personal data spreads to every subscriber, log and dead-letter container.
Correct Approach
Use identity-based publishing with minimal roles, rotate or disable keys, and keep events small with identifiers instead of sensitive content.
Trusting incoming webhook calls just because they look like Event Grid. If you receive events on your own endpoint, validate them using the supported authentication method so that a stranger cannot call your endpoint pretending to be Event Grid.
17Monitoring, Diagnostics and Troubleshooting
Event-driven systems are quiet when they work and puzzling when they do not. Make them observable.
What to watch
Published events
Counts of events accepted and rejected by the topic. A fall may mean a publisher problem; rejections suggest authentication or format issues.
Matched and delivered events
How many events matched a subscription and how many were delivered successfully.
Failed deliveries
Counts of attempts that failed, often broken down by error type. A sustained rise points to a handler or network problem.
Dropped and dead-lettered events
Events that expired or were stored as undeliverable. These should be near zero and always investigated.
Delivery latency
How long it takes to deliver. Rising latency suggests throttling or a slow endpoint.
flowchart LR
EG["Event Grid topics and subscriptions"] --> M["Metrics"]
EG --> D["Diagnostic logs for delivery failures and publish errors"]
M --> AL["Alert rules"]
D --> LA["Log Analytics workspace"]
LA --> AL
AL --> AG["Action group"]
AG --> T["Team channel or on-call tool"]
Troubleshooting checklist
| Symptom | Likely cause | What to check |
|---|---|---|
| Subscription creation fails | Webhook validation not answered or blocked | Confirm the endpoint is reachable and handles the validation event |
| No events arrive | Filters too narrow, publisher not sending, wrong topic | Check published and matched counts, filter patterns and subject format |
| Events published but not matched | Event type or subject differs from the filter | Compare a real event with the filter, including case sensitivity |
| Deliveries failing | Handler down, slow or returning errors; authorization problems | Read failure reasons in diagnostics and test the handler directly |
| Duplicate processing | At-least-once delivery, timeouts causing retries | Make handlers idempotent; respond quickly and process asynchronously |
| Events in dead-letter storage | Retries exhausted | Read the reason, fix the cause, then replay |
| Publisher gets unauthorized errors | Missing role, expired key or wrong audience | Check identity, role assignment and endpoint |
| Works in test but not production | Firewall, private networking or identity differences | Compare network rules and identities between environments |
If a department says it never got a notice, check in order: was the notice posted, did it match the request slip, was the department reachable, and is it in the undelivered tray. Counters at each stage tell you where the notice stopped.
Put a correlation identifier in each event and log it in every handler. When something goes wrong, you can follow one business happening across publisher, Event Grid and all handlers with a single search.
18Reliability, Ordering and Disaster Recovery
Events are only useful if they survive failures, so plan for the bad days.
What the service gives you
Event Grid is built on regional infrastructure with redundancy within the region, and it can use availability zones in supported regions. Once an event is accepted, it is stored and delivered with retries as described earlier. The service does not guarantee ordering, and it does not keep events forever; its job is to deliver or dead-letter them.
Regional failures
For regional disasters, Event Grid has offered geo-disaster recovery features for custom topics and domains, with options to publish to a paired secondary topic, and to fail over. The details, including which topic types support them and who controls failover, have changed over time, so verify the current model. A common design is to keep a matching topic and subscriptions in a second region, defined as code, and make publishers capable of switching if the primary is unreachable.
flowchart LR
PUB["Publisher with failover logic"] --> P["Primary region topic"]
PUB -.->|If primary unreachable| S["Secondary region topic"]
P --> H1["Handlers in primary region"]
S --> H2["Handlers in secondary region"]
REPO["Templates in source control"] --> P
REPO --> S
Define everything as code
Topics, subscriptions, filters and dead-letter settings in templates, so a second region can be created and tested quickly.
Plan for handler failure
Dead-letter and queue buffers protect against handler outages. Test recovery by replaying events.
Do not rely on order
Design handlers to tolerate out-of-order events using version numbers or timestamps.
Rehearse failover
Practice switching publishers and measure how many events may be lost or duplicated during the switch.
A building with a backup front desk in the building next door can keep announcing notices if the main lobby is closed. But staff must know the backup exists, rehearse using it, and accept that a few notices may be repeated or delayed during the switch.
Recovery options differ between topic types and between the classic service and namespaces, and the responsibilities of Microsoft and customers during failover have been changing. Read the current resilience guidance before promising any recovery objective to the business.
19Cost Management
Event Grid is usually inexpensive, but high volumes and extra features add up.
For the classic service, pricing is generally based on the number of operations, counting things like event publishes, delivery attempts, advanced filter evaluations and management calls, with a monthly free allowance and a price per million operations beyond it. Namespace features such as MQTT and pull delivery use their own models, based on throughput units or similar capacity concepts plus per-operation charges. Related services such as storage for dead-lettering, queues, functions and logging add their own costs. Prices change, so confirm on the current pricing page before budgeting.
Filter early
Deliver only what handlers need. Fewer deliveries mean fewer operations and less downstream compute.
Batch when possible
Publish and deliver events in batches for high-volume flows, where handlers support it.
Tune retries and time to live
Endless retries to a dead endpoint waste operations. Disable or fix failing subscriptions quickly.
Avoid chatty event design
Do not announce every tiny internal step. Publish meaningful business facts.
Watch downstream cost
A function run per event or a workflow action per event can cost more than Event Grid itself. Estimate the whole chain.
Clean up unused subscriptions
Review regularly and remove those without owners or purpose.
The announcement system charges a tiny fee per announcement and per delivery attempt. The big cost is usually not the announcement itself but the work every department does in response, so the best saving is not announcing things nobody needs.
A feedback loop: a function reacts to a storage event by writing a file to the same storage location, which raises another event, which triggers the function again. Costs and load explode quickly. Separate input and output locations, filter carefully and set alerts on event volume.
20Governance, Naming and Organization
Event-driven systems are easy to start and hard to understand once there are hundreds of subscriptions.
| Area | Recommendation |
|---|---|
| Naming | Use consistent names for topics, subscriptions and event types that show domain, environment and purpose |
| Catalog | Maintain a catalog of event types with owner, schema, version, meaning and example |
| Ownership | Each topic and subscription has an owning team and a contact, recorded in tags |
| Environments | Separate topics for development, test and production, with different access |
| Change management | Treat event schemas as public contracts; announce and version changes |
| Infrastructure as code | Define topics and subscriptions in templates under review |
| Policy | Use Azure Policy to enforce private access, identity-based authentication and diagnostic settings |
A building with a hundred notice boards and no directory becomes chaos. A directory listing each board, who owns it, what it is for and who reads it keeps the building understandable as it grows.
Before adding a new event type, check the catalog for an existing one. Before changing an event, find out who subscribes. The costliest event bugs are changes that silently break unknown consumers.
Problem
Teams change field names in their event data to suit themselves, without telling anyone, and nobody keeps a list of subscribers.
Why It’s Harmful
Consumers break silently, often discovered by customers, and the cause is hard to trace because publisher and consumer teams never talk.
Correct Approach
Version schemas, add fields instead of renaming, keep a catalog of events and subscribers, and announce changes in advance.
21Patterns and Anti-Patterns
Habits that make event-driven systems dependable, and habits that make them fragile.
Patterns worth adopting
Idempotent handlers everywhere
Assume every event may arrive twice or out of order and design handlers so that this causes no harm.
Small events with identifiers
Announce the fact and where to find details. Avoid carrying large or sensitive content.
Dead-letter and replay discipline
Always configure dead-lettering, alert on it, and keep a tested procedure to replay events after a fix.
Queue in front of fragile or slow handlers
Buffer so that bursts and outages do not lose events or overwhelm the handler.
Identity-based everything
Managed identities for publishers, deliveries and dead-letter storage, with roles limited to what is needed.
Event catalog and schema versioning
Treat event contracts as a product, with owners, documentation and change notices.
Correlation identifiers
Carry a trace identifier in every event so that business flows can be followed across services.
More anti-patterns to avoid
Problem
Event Grid is used as a request-and-response channel, with a service publishing an event and waiting for another service to answer.
Why It’s Harmful
Event Grid offers no ordering, no reply mechanism and no latency promise for a waiting caller. The design is fragile and hard to debug.
Correct Approach
Use direct calls for request and response, or messaging with reply queues, and keep events for announcements.
Problem
Event Grid is used to carry a high-volume continuous stream of telemetry from thousands of devices.
Why It’s Harmful
The service and its pricing are designed for discrete events, not for streaming analytics, and costs and limits become painful.
Correct Approach
Use a streaming service for the flow and Event Grid for the discrete reactions, or use the namespace MQTT features where device messaging is the real need.
Problem
A system depends on events arriving exactly once and in order, for example updating a balance by adding each event’s amount.
Why It’s Harmful
Duplicates or reordering corrupt the result silently.
Correct Approach
Use idempotency keys and version checks, or route the critical flow through a messaging service with ordering and duplicate detection.
22Best Practices Checklist
A review list to use before going live and at regular intervals afterward.
Do
- Use events for discrete facts and messages for work that must be done
- Name events in the past tense with consistent, namespaced types
- Prefer the CloudEvents standard for new designs where supported
- Filter in the subscription and give each handler its own subscription
- Make handlers idempotent and tolerant of disorder
- Configure dead-lettering and monitor it
- Put a queue in front of slow, fragile or bursty handlers
- Use Microsoft Entra identities and managed identities instead of shared keys
- Use private endpoints and restricted networks when policy demands
- Keep events small and free of secrets and unnecessary personal data
- Define resources as code and maintain an event catalog
- Alert on failed deliveries, dead-letters and unexpected volume
Avoid
- Using events as commands or as request and response
- Assuming exactly-once delivery or strict ordering
- Sharing one subscription between unrelated handlers
- Embedding keys in applications and sharing them widely
- Large payloads and sensitive data inside events
- Feedback loops where a reaction creates the event that triggered it
- Changing event data shapes without versioning or notice
- Streaming continuous high-volume telemetry through discrete event topics
- Leaving failing subscriptions running untouched
Hold a short event review every quarter: which event types and subscriptions are still used, which have no owner, how many events were dead-lettered, what the cost is, and whether any feature you rely on is changing.
23Real-World Scenarios
How organizations put Event Grid to work.
Document processing pipeline
A legal firm receives scanned documents into storage. A storage event, filtered to the incoming folder and the right file types, starts a function that extracts text and stores the result. Another subscription sends a copy of the event to a queue for the archiving system, and a third notifies the case team. Dead-lettering captures any that fail so that nothing is lost.
Retail order flow
An online retailer publishes “order placed” to a custom topic. Payment, inventory, email notification and fraud-checking services each subscribe with their own filters. Later the retailer adds a loyalty points service by creating a new subscription, with no change to the order service.
Cloud governance and compliance
A company subscribes to resource events at subscription level. A function inspects each new resource, applies missing tags, flags insecure settings and raises tickets for exceptions. Auditors see a continuous, evidence-backed process rather than a quarterly spreadsheet.
Software vendor exposing events to customers
A software-as-a-service vendor uses an event domain with one topic per customer. Customers get rights only to their own topic and subscribe their own webhooks, so each customer is told about changes in their own data without the vendor building custom integrations.
Smart building devices
Thousands of sensors and controllers connect to an MQTT broker in an Event Grid namespace. Control applications subscribe to device channels, while selected messages are routed onward to a pulled topic where a processing service, behind a firewall, fetches them at its own pace.
Secret and certificate lifecycle
Key Vault events announce near-expiry certificates. A workflow renews them, updates dependent applications and posts a summary to the team channel, and the whole lifecycle is logged for auditors.
24Frequently Asked Questions
Short answers to common beginner questions.
It is a managed Azure service that routes events from sources such as Azure services and your applications to handlers that have subscribed, with filtering, retries and dead-lettering built in.
A small record stating that something happened, with an identifier, a type, a subject, a time and some details.
A topic is where events are sent. A subscription belongs to a topic and says which events go to which handler and how delivery behaves.
No. Push delivery is at least once, and order is not guaranteed, so handlers must tolerate duplicates and disorder.
Event Grid retries with increasing waits for the configured time. If it still fails, the event is dead-lettered to storage if you configured that, otherwise dropped.
Use Event Grid to announce that something happened to many listeners. Use Service Bus when a message represents work that must be processed reliably, possibly in order, by one consumer.
The classic service is built for discrete events. For continuous streams, Event Hubs is the usual choice. The newer namespace MQTT broker addresses device messaging, but check current limits and features.
In push, Event Grid calls your handler. In pull, your handler connects and fetches events at its own pace, then acknowledges them. Pull suits private or rate-limited consumers.
Usually because the endpoint did not answer the validation handshake, or the request was blocked by a firewall or gateway.
Use Microsoft Entra identities with a data sender role, restrict network access, and avoid or rotate access keys. Keep secrets out of event data.
Make handlers idempotent by recording processed event identifiers or using operations that give the same result when repeated.
Mainly per operation, with a free monthly allowance for the classic service, and capacity plus operation charges for namespace features. Downstream compute and storage often cost more. Check the current pricing page.
The concepts are stable, but features, schemas, limits, supported sources, namespace capabilities and prices change. Confirm details in the current official documentation before finalizing a design.
25Summary and Key Takeaways
Event Grid is the announcement system of your cloud. Sources publish small, factual events to topics; subscriptions filter them and deliver copies to handlers such as functions, workflows, queues and web services. The system retries with backoff, saves undelivered events in a dead-letter location, and scales without servers to manage. Because delivery is at least once and unordered, handlers must be idempotent and tolerant of disorder, and fragile handlers belong behind queues. Security rests on identities, narrow roles, careful network control and small events free of sensitive data. The newer namespace features add an MQTT broker for devices and pull delivery for controlled consumers, while Service Bus and Event Hubs remain the right tools for reliable work messages and high-volume streams. Because capabilities and pricing keep evolving, hold on to the lasting ideas in this guide and verify the details in current documentation. With these habits, your systems stop polling and start listening, and they grow by adding subscribers instead of rewriting senders.
Key Takeaways
- Announce facts, do not issue commands — events say what happened; use messages and queues when work must be done reliably by one processor.
- Know the vocabulary — source, topic, subscription, handler and schema explain almost every design, with system, custom, partner and domain topics covering different publishers.
- Filter early and separate handlers — use event type, subject and advanced filters in the subscription, and give each handler its own subscription.
- Design for at-least-once, unordered delivery — idempotent handlers, version checks, and queues in front of slow or bursty consumers.
- Always dead-letter and watch it — configure storage for undeliverable events, alert on them, and rehearse replay.
- Secure by identity — Entra identities, managed identities, narrow roles, private networking where required, and small events without secrets.
- Choose the right service and verify the details — Event Grid for discrete notifications, Service Bus for reliable work, Event Hubs for streams, and confirm current features, schemas and prices before building.