HomeAbout Me

Azure EventHub and Service Bus Integration | Azure Function Trigger with Service Bus output Binding

By Sri Gunnala
Published in Microsoft Azure
September 03, 2025
1 min read
Azure EventHub and Service Bus Integration | Azure Function Trigger with Service Bus output Binding

Summary: Learn how to combine Azure Event Hub and Service Bus for scalable, real-time event ingestion and reliable downstream processing. This post covers architecture, real-world use cases, and a hands-on demo with Azure Functions.

Azure Event Hub + Service Bus: Scalable Streaming Meets Reliable Messaging

Integrating Azure Event Hub and Service Bus lets you build data pipelines that handle massive event volumes and guarantee delivery for critical messages. Here’s how they work together:


What Are They?

  • Azure Event Hub: Big data streaming platform for high-throughput event ingestion (IoT, telemetry, app events). Handles millions of events per second, ideal for real-time processing. Not built for guaranteed delivery.
  • Azure Service Bus: Messaging service for reliable, decoupled communication between systems. Supports queues, topics, guaranteed delivery, retries, and message ordering.

Why Integrate Event Hub and Service Bus?

Combining these services gives you:

  • Real-time event ingestion at scale
  • Guaranteed delivery for important messages
  • Decoupling producers from consumers
  • Multiple subscribers via topics
  • Reliable error handling (retries, dead-letter queues)
  • Scalable microservices architecture

Real-World Use Case: Smart City Traffic Management

Imagine IoT sensors across a city (roads, traffic lights, emergency routes) streaming data like vehicle speed, congestion, and emergency detection into Event Hub. An Azure Function processes these events, identifies critical ones (e.g., emergency vehicles), and pushes them to a Service Bus Topic. Multiple downstream systems (emergency response, traffic control) subscribe and act in real time.

graph TD
    Sensors[IoT Sensors]
    EventHub[Azure Event Hub]
    Function[Azure Function]
    ServiceBus[Azure Service Bus Topic]
    Subscribers[Downstream Subscribers]
    Sensors -->|Telemetry| EventHub
    EventHub -->|Trigger| Function
    Function -->|Critical Events| ServiceBus
    ServiceBus -->|Guaranteed Delivery| Subscribers

Demo: Event Hub Trigger to Service Bus Topic with Azure Functions

1. Create Resources

  • Event Hub Namespace & Event Hub (e.g., infacto)
  • Service Bus Namespace & Topic (e.g., test-en-topic)
  • Subscription under the topic (e.g., all)

2. Azure Function Setup

  • Create an Azure Function App with an Event Hub Trigger
  • Configure connection strings in local.settings.json

3. Event Hub Trigger Function

[Function("EventHubServiceBusIntegration")]
public async Task<string> Run(
    [EventHubTrigger("infacto", Connection = "EventHubConnection")] string eventData,
    [ServiceBusOutput("test-en-topic", Connection = "ServiceBusConnection", EntityType = ServiceBusEntityType.Topic)]
    out string outputMessage,
    ILogger log)
{
    log.LogInformation($"Received event: {eventData}");
    // Inspect event, filter critical messages
    var isCritical = CheckIfCritical(eventData);
    outputMessage = isCritical ? eventData : null;
    return outputMessage;
}

4. Test the Flow

  • Send a sample event via Event Hub Data Explorer
  • Azure Function logs the event and, if critical, forwards to Service Bus Topic
  • Downstream systems pick up messages from the topic

Key Takeaways

  • Event Hub: Scalable, real-time event ingestion
  • Service Bus: Reliable, guaranteed delivery for critical messages
  • Azure Function: Bridges the two, enabling intelligent filtering and routing
  • Topics & Subscriptions: Support multiple consumers and decoupled architectures

Photo/Thumbnail by Tolga Ulkan on Unsplash

Tags

#Azure#EventHub#ServiceBus#Integration
Previous Article
Azure API Management (APIM) | Internal Mode | Forced Tunneling | Connectivity Error | Virtual Appliance
Sri Gunnala

Sri Gunnala

Learner | Reader | Blogger | Azure Enthusiast

Topics

Front End
Microsoft Azure
Microsoft .NET

Newsletter

Sri Gunnala - Make sure to subscribe to newsletter and be the first to know the news.

Related Posts

Front your Power Apps(pages) with Azure Front Door and WAF
September 21, 2025
2 min

Legal Stuff

Privacy NoticeCookie PolicyTerms Of Use

Social Media