Search code examples
azureazure-functionsazure-eventhub

How to route Event Hub messages to different Azure functions based on their message type


I have an Azure Event Hub over which I would like to send various types of messages. Each message should be handled by a separate Azure Function, based on their message type. What is the best way to accomplish this?

Actually, I could create some JSON container with a type and payload property and let one parent Azure Function dispatch all the messages payloads - based on their type - to other functions, but that feels a bit hacky.

This question basically asks the same - however it is answered how it can be done using the IoT Hub and message routing. In the Event Hub configuration I cannot find any setting to configure message routing though.

Or should I switch to an Azure Message Queue to get this functionality?


Solution

  • I ended up using Azure Durable Functions using the Fan Out/Fan In pattern.

    In this approach, all events are handled by a single Orchestrator Function which in fact is a Durable Azure Function (F1). This deserializes incoming JSON to the correct DTO. Based on the content of the DTO, a corresponding activity function (F2) is invoked which processes it.

    enter image description here