Filtering EventGrid Topic MQTT Messages

Mark Pope 50 Reputation points
2025-04-23T16:50:13.8433333+00:00

I need to subscribe to an external MQTT broker and publish MQTT messages received from the Azure Event Grid. I created a Function App that triggers on MQTT messages. The function app must interrogate each message and call one of several MQTT clients based on who should receive the topic. With decoding this seems like an inefficient solution. Another solution is to have Function app subscribe to Event Grid topic spaces as MQTT clients, allowing them to collect the correct topics and publish to appropriate clients(brokers). Thoughts?

Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
439 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 36,146 Reputation points MVP
    2025-04-23T17:31:39.15+00:00

    Hello @Mark Pope ,

    welcome to this moderated Azure community forum.

    It seems you want to have this architecture:

    External MQTT broker <- Some client in an Azure Function checking each message and picking the right topic to publish to-> EventGrid Namespace MQTT Broker <- One or more possible clients listening to topics

    Function apps are stateless and not suitable for long running services (listening as a subscriber for messages). It also means constant connect/disconnect.

    One way to overcome this is to move over to an Azure Container Instance because it is stateful.

    Check out this example with code. In this case, it reads messages from an Azure EventHub but the blue print should help you with building a stable solution.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.