Pipe Events from Azure Event Hub to Azure Service Bus
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Azure Event Hubs and Azure Service Bus are both crucial components in the Azure messaging ecosystem. They provide different capabilities tailored to specific needs in an application's infrastructure for handling events and messages. Pipelining events from Azure Event Hubs to Azure Service Bus can enhance application scalability, reliability, and flexibility by leveraging the unique capabilities of both services.
Understanding Azure Event Hubs and Azure Service Bus
Azure Event Hubs
Azure Event Hubs is a highly scalable data streaming platform and event ingestion service, capable of receiving and processing millions of events per second. Event Hubs can store and process massive amounts of data that can be transformed and sent to various recipients, such as Azure Blob Storage, Azure Data Lake, Azure Service Bus, and more.
Azure Service Bus
Azure Service Bus is a more traditional message broker with different communication mechanisms like queues, topics, and subscriptions. It supports complex messaging features like FIFO (First-In, First-Out) messaging, session-based routing, and dead-lettering, which are not inherently available in Event Hubs.
Why Pipe Events from Azure Event Hubs to Azure Service Bus?
There are several reasons why one might want to pipe data from Azure Event Hubs to Azure Service Bus:
- Complex Message Routing: Service Bus provides more sophisticated message routing options like topics and subscriptions which are useful for delivering a message to multiple subscribers.
- Message Handling Features: Features like scheduled delivery, duplicate detection, and dead-lettering in Azure Service Bus can handle messages more flexibly.
- Integration Requirements: Some existing systems might use Service Bus extensively and integrating with Event Hubs requires a bridging mechanism.
- Load Levelling: Service Bus can act as a buffer to manage load spikes by decoupling data ingestion from data processing.
How to Pipe Events from Event Hubs to Service Bus
To pipe events from Azure Event Hubs to Azure Service Bus, you can use Azure Functions, which serve as a bridge in this architecture. Here’s a basic outline of how this can be achieved using Azure Functions:
Step 1: Create Event Hub and Service Bus
First, you need an Azure Event Hub and a Service Bus namespace, along with a queue or topic in Service Bus.
Step 2: Setup Azure Function
Create an Azure Function with an Event Hub Trigger and configure the trigger to point to your particular Event Hub namespace and event hub. Additionally, setup an output binding for the Azure Service Bus.
Example Function Code
Here is an example of an Azure Function written in C# that triggers on an event in Azure Event Hubs and sends a message to Azure Service Bus:
Configuration
Ensure that you add the necessary connection strings for both the Event Hub and the Service Bus in the application settings of the Function App.
Practical Considerations
When integrating Event Hubs with Service Bus, there are several practical aspects to consider, summarized in the following table:
| Aspect | Event Hubs | Service Bus | Consideration |
| Throughput | High (Millions of events/sec) | Lower compared to Event Hubs | Choose based on the volume and velocity of data |
| Message Retention | Up to 7 days | Indefinite (with TTL settings) | Choose based on how long messages need to be retained |
| Features | Simplistic Pub/Sub | Advanced features like dead lettering, sessions | Use Service Bus for advanced messaging requirements |
| Scaling | Auto-scales | Requires manual scaling | Consider the scaling needs of your application |
Conclusion
Integrating Azure Event Hubs with Azure Service Bus using Azure Functions is a powerful pattern to enhance the capabilities of a cloud-based messaging system. This setup leverages the high throughput of Event Hubs with the sophisticated messaging capabilities of Service Bus, providing a robust infrastructure for handling large-scale, complex messaging scenarios in Azure.
Related reading
- Pitfalls with local in memory cache invalidated using RabbitMQ
- Pivot Kafka KTable results using flatMap
- Poll Interval for Kafka Connect SourceTask
- Poor performance of log4j2 in combination with Kafka
- Placing Files In A Kubernetes Persistent Volume Store On GKE
- Pod CPU Throttling
- Poor performance with Spark streaming, Kafka and multiple topics
- Porting Kafka's murmur2 implementation to Go

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.