Event-Driven Architecture
Azure Event Grid, Event Hubs, and reactive patterns β design systems that respond to events in real-time with fan-out, filtering, and massive throughput.
Event-driven design
Events are notifications that something happened. βA file was uploaded.β βA user signed in.β βA temperature sensor reading exceeded 100Β°C.β Unlike messages (commands), events donβt tell anyone what to do β they just announce what happened.
Event Grid: Routes events from Azure services to handlers. Low latency, per-event pricing. Like a postal service for notifications.
Event Hubs: Ingests millions of events per second for streaming analytics. Like a firehose for telemetry data.
The distinction matters for AZ-305: Event Grid for reactive event routing, Event Hubs for high-throughput streaming.
Event Grid vs Event Hubs
| Factor | Event Grid | Event Hubs |
|---|---|---|
| Pattern | Reactive event routing (push) | Big data streaming (pull) |
| Throughput | 10M events/sec per topic | Millions of events/sec per namespace |
| Latency | Sub-second (real-time push) | Low (consumer pulls at own pace) |
| Delivery model | Push to subscribers (webhook, Functions, queues) | Pull by consumer groups (partition-based) |
| Event retention | 24 hours (retry window) | Standard: up to 7 days; Premium/Dedicated: up to 90 days (use Capture for long-term archive) |
| Filtering | Yes β subject prefix, suffix, advanced filters | No β consumers read all events in partition |
| Ordering | Not guaranteed | Guaranteed within partition |
| Replay/reprocess | No β events pushed once (with retry) | Yes β consumers can rewind and replay |
| Cost model | Per-event ($0.60/million) | Throughput units + storage |
| Best for | Azure service events, webhooks, reactive automation | IoT telemetry, clickstream, log aggregation, SIEM ingestion |
The exam distinction: Event Grid = βsomething happened, react to itβ (push). Event Hubs = βcapture everything for processingβ (pull). If the scenario says βrespond when a blob is createdβ β Event Grid. If it says βingest 1 million sensor readings per secondβ β Event Hubs.
Event Grid use cases
| Event Source | Event | Handler | Scenario |
|---|---|---|---|
| Blob Storage | Blob created | Azure Function | Process uploaded images (resize, thumbnail) |
| Resource Group | Resource modified | Logic App | Notify team when resource config changes |
| Entra ID | User provisioned | Function | Auto-assign licenses to new users |
| Custom app | Order placed | Service Bus queue | Fan-out to fulfilment, billing, notification |
Event Hubs use cases
| Event Source | Volume | Consumer | Scenario |
|---|---|---|---|
| IoT devices | 1M events/sec | Stream Analytics | Real-time temperature monitoring |
| Web clickstream | 100K events/sec | Databricks | User behaviour analytics |
| Application logs | 500K events/sec | Azure Sentinel | Security event correlation |
| Financial trades | 50K events/sec | Custom consumer | Real-time risk calculation |
π¦ Elenaβs event architecture:
- Event Grid triggers a Function when audit logs arrive in Blob Storage β parses and indexes for compliance search
- Event Hubs ingests card transactions at 10M/hour β Stream Analytics detects fraud patterns β alerts via Functions
The full messaging/event landscape
| Service | Pattern | Key Signal |
|---|---|---|
| Queue Storage | Simple queuing | High volume, low cost, no ordering needed |
| Service Bus | Enterprise messaging | FIFO ordering, transactions, dead-letter, pub-sub |
| Event Grid | Reactive event routing | Push events to handlers, filtering, Azure service integration |
| Event Hubs | Streaming ingestion | Millions of events/sec, replay, analytics pipeline |
Knowledge check
π¦ Elena needs to detect fraudulent card transactions in real-time. The system ingests 10 million transactions per hour, and fraud detection rules must process the stream continuously. Suspicious transactions need to be stored for investigation with the ability to replay and reprocess. Which service should Elena recommend for event ingestion?
ποΈ GlobalTech uploads thousands of invoices daily to Azure Blob Storage. Each invoice must be automatically processed by an Azure Function that extracts data using Form Recognizer, then stores results in Cosmos DB. The solution must handle processing failures with retry. Which event-driven pattern should Priya recommend?
π¬ Video coming soon
Next up: How services expose their functionality β API Integration & Caching.