Designing with Event Grid and Event Hubs
This lesson explains discrete events, event streams and the services for each.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish discrete events from event streams.
- Compare Event Grid, Event Hubs and Service Bus.
- Identify design considerations for consumers.
Event-driven design
In an event-driven architecture, a producer publishes events without knowing which consumers exist. New consumers can be added without changing the producer, so systems can evolve independently. Two broad event styles apply. Discrete events report a state change that a consumer acts on, such as a blob being created. An event stream is a continuous series of events, usually high-volume, that a consumer analyses as a whole, such as telemetry from thousands of devices.
Azure Event Grid
Azure Event Grid is an event routing service. Many Azure services publish events natively, such as a storage account reporting a new blob, and applications can publish custom events. Subscriptions filter events and deliver them to handlers such as Azure Functions, Logic Apps or webhooks. Delivery is push-based, close to real time, and uses a 24-hour retry mechanism with exponential backoff, with undelivered events able to go to a dead-letter location.
Event Grid eliminates polling. Instead of a function checking a container each minute, Event Grid notifies the function as soon as a blob appears. Event Grid namespaces add an MQTT broker, supporting MQTT v3.1.1 and v5.0, for device communication, along with pull delivery of events.
Azure Event Hubs
Azure Event Hubs is a big data streaming platform that ingests millions of events a second. Producers write to an event hub, which divides data into partitions. Consumers read at their own pace, each consumer group holding its own position in the stream, and events are retained for a period, so a consumer can replay them. This pull model differs fundamentally from a broker that deletes a message once it is processed.
Event Hubs has a Kafka-compatible endpoint, so that existing Kafka clients can connect with a configuration change, without running a Kafka cluster. Capture automatically saves streaming data to Blob Storage or Data Lake Storage for later batch use. Capacity tiers differ in retention and isolation: Standard retains events for up to 7 days and uses throughput units; Premium and Dedicated retain them for up to 90 days, and use processing units and capacity units respectively.
Comparing the services
The three services are complementary. Microsoft's comparison summarizes their purposes as follows, and a single solution often uses more than one, such as Event Hubs for telemetry and Service Bus for commands.
The following diagram shows two event paths, one for vehicle telemetry and one for discrete business events.

Event Grid, Event Hubs or Service Bus?
Design considerations
Consumers of events must allow for at-least-once delivery, by being idempotent, since an event might arrive twice. Ordering in Event Hubs is guaranteed only within a partition, so a partition key should group related events, such as those from one device. Too few partitions limit parallel consumers, and the partition count deserves thought because it is difficult to change in lower tiers.
Events should remain small. The claim check pattern places a large payload in Blob Storage, and the event carries only a reference to it. A dead-letter destination should be set, in order to catch failures. Consumers should also be monitored for lag, which shows how far behind real time they are.
Designing event consumers
Telemetry and reactions
A logistics company has 100,000 vehicles sending location data every second. Dashboards read this stream, and a data science team must replay the last week to test new models. When a video file reaches a storage account, a function must start immediately. The team has existing Kafka producers. What should you recommend?
Azure Event Hubs fits the telemetry. It handles this volume, retains data for replay, and its Kafka endpoint lets existing producers connect without running a Kafka cluster. Seven-day replay fits the Standard tier's maximum retention.
The storage trigger suits Azure Event Grid, which pushes a blob-created event to the function immediately, with no polling. Service Bus would be overwhelmed by the telemetry and has no replay, whereas polling the storage account from a timer function would add delay and cost.
Can a consumer reread an hour-old event in Azure Event Hubs?
Show answer
Yes, within the retention period, because consumers track their own position in the stream.
Exam Tips
Remember for the exam
- Event Grid reacts to discrete events; Event Hubs ingests streams; Service Bus carries commands.
- Event Hubs supports replay and a Kafka endpoint; ordering holds only within a partition.
- Event Grid retries for 24 hours with exponential backoff.
- Consumers must be idempotent, because delivery is at least once.