Design infrastructure solutions · Topic 3 of 10
Messaging and Event Driven Architecture
AZ-305 integration design: choose Service Bus, Storage queues, Event Grid and Event Hubs for messages, events and streams, and design event driven systems.
- 5 min
- Includes a diagram
- Service Bus gives ordering with sessions, transactions, duplicate detection, dead lettering and topics. Storage queues give none of these but hold huge backlogs.
- Event Grid routes discrete events with push delivery and no ordering. Event Hubs streams high volume data with partitions, replay and Kafka support.
- Ordering in Event Hubs is only within a partition.
What it is
Loosely coupled systems talk through messages and events instead of direct calls. A message carries data that one component wants another to process, and the sender expects it to be handled. An event announces that something happened, and the sender does not care who reacts. A stream is a high volume sequence of events read by analysers. Azure has a service for each pattern, and picking the right one is a classic design question.
How it works
The four services
| Service | Pattern | Best for |
|---|---|---|
| Azure Service Bus | Enterprise messaging (queues and topics) | Reliable business transactions between apps, ordering, transactions |
| Azure Storage queues | Simple queue | Very large backlogs of basic work items at low cost |
| Azure Event Grid | Event routing (push) | Reacting to state changes, such as a blob created or a resource changed |
| Azure Event Hubs | Event streaming | Telemetry and log ingestion at huge scale, replay by consumers |
Service Bus features
| Feature | Behaviour |
|---|---|
| Queues | Point to point. One consumer processes each message |
| Topics and subscriptions | Publish and subscribe. Each subscription gets a copy, with filters and rules |
| Sessions | First in, first out ordering per session id |
| Dead letter queue | Automatically holds messages that fail or expire, for investigation |
| Duplicate detection | Drops duplicate messages within a time window |
| Transactions | Group operations atomically |
| Scheduled and deferred messages | Deliver later |
| Premium tier | Dedicated capacity, large messages, zone redundancy, private endpoints, geo disaster recovery pairing |
Use Service Bus when the requirement mentions ordering, transactions, duplicate detection, dead lettering or pub/sub with filters. A common pattern is competing consumers: several workers read one queue to scale out processing.
Storage queues
Storage queues are simple and cheap, hold more than 80 GB of messages, and give server side logs. They have no ordering guarantee, duplicate detection or automatic dead lettering. Choose them for a large backlog of simple tasks with no advanced needs.
Event Grid and Event Hubs
- Event Grid is a push based event router. Publishers include Azure services and custom topics, and subscribers include Functions, Logic Apps, webhooks, Service Bus and Event Hubs. It has retry and dead lettering, no ordering guarantee, and it handles discrete events.
- Event Hubs receives millions of events per second into partitions. Consumers read independently with consumer groups and can replay from an offset. Ordering is guaranteed only within a partition. It has Kafka protocol compatibility and Capture to write data to storage. Stream processing uses Stream Analytics, Spark or Functions.
Choosing between them

| Requirement | Choice |
|---|---|
| Orders must be processed in sequence per customer | Service Bus queue with sessions |
| Bad messages must go to a dead letter store | Service Bus |
| One event, many independent subscribers with filters | Service Bus topic, or Event Grid |
| React to a blob upload or resource change | Event Grid |
| Ingest telemetry from thousands of devices | Event Hubs (or IoT Hub) |
| Massive simple backlog, lowest cost | Storage queue |
| A workflow where an event triggers a business process | Event Grid sends to a Service Bus queue |
Event driven architecture patterns
- Publish and subscribe decouples senders from receivers.
- Competing consumers scale processing across workers.
- Queue based load leveling absorbs bursts so the back end is not overwhelmed.
- Event sourcing and CQRS store events as the source of truth.
- Saga coordinates a transaction across services with compensating steps.
- Idempotent consumers handle at least once delivery safely, because all these services deliver at least once.
- Outbox pattern ensures a database change and a message are published together.
- Combine services: Event Grid to Service Bus for reliable processing, or Event Hubs Capture to a lake.
A worked scenario
An order platform places orders on a Service Bus topic so billing, shipping and email each have a subscription with filters, using sessions to keep each customer's messages in order and the dead letter queue for failures. Warehouse sensors stream events into Event Hubs. When a blob lands in storage, Event Grid triggers a function that validates the file. Consumers are idempotent to cope with duplicates.
What to remember for the exam
- Service Bus gives ordering with sessions, transactions, duplicate detection, dead lettering and topics. Storage queues give none of these but hold huge backlogs.
- Event Grid routes discrete events with push delivery and no ordering. Event Hubs streams high volume data with partitions, replay and Kafka support.
- Ordering in Event Hubs is only within a partition.
- All the services deliver at least once, so consumers should be idempotent.
- Service Bus Premium adds zone redundancy and geo disaster recovery pairing.
A message that must be processed is Service Bus. An event that merely announces something is Event Grid. A firehose is Event Hubs.
How the exam asks about this
- "Messages must be processed in order per customer, with a dead letter queue." Service Bus with sessions.
- "React when a file is created in storage." Event Grid.
- "Ingest telemetry from millions of devices and process it later." Event Hubs.
- "Store more than 80 GB of simple queued work cheaply." Storage queues.
Common mistakes
Using Event Grid for ordered work. It does not guarantee order.
Storage queues when duplicate detection is required.
Assuming exactly once delivery. Design idempotent consumers.
Using Event Hubs as a work queue.
Check yourself
Which service provides sessions for ordered processing?
Azure Service Bus.
Which service routes discrete events with push delivery?
Azure Event Grid.
Where is ordering guaranteed in Event Hubs?
Within a partition.
Topic 3 of 10 in Design infrastructure solutions
Test yourself on Design infrastructure solutions
The full Microsoft AZ-305 question bank has 755 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Microsoft. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.