Share via

Send command from my backend service to eventgrid client

Ansh Thapliyal 20 Reputation points
2026-01-30T10:46:54.29+00:00

I am able to send the device to cloud messages and receive on my backend service using eventgrid namespace topic-space feature. However, i am unbale to find a way to send cloud to deivice messages to my eventgrid client using eventgrid namespace mqtt feature as i am unable to select endpoint topic space in topic subscription. Is there any way or am i doing anything wrong? I am able to send messages using mqtt client factory using another client directly to a topic space where my device is subscribed to. But i want to implement c2d flow where i am able to send messages to device using my backebd service.

Azure Event Grid
Azure Event Grid

An Azure event routing service designed for high availability, consistent performance, and dynamic scale.

0 comments No comments

Answer accepted by question author
  1. Siddhesh Desai 4,895 Reputation points Microsoft External Staff Moderator
    2026-01-30T11:08:02.1766667+00:00

    Hi @Ansh Thapliyal

    Thank you for reaching out to Microsoft Q&A.

    The behavior you’re experiencing is expected with Azure Event Grid Namespace when using the MQTT broker feature and Topic Spaces. Topic Spaces are an MQTT‑only construct that exists inside the Event Grid MQTT broker to manage topic templates, access control, and publish/subscribe permissions for MQTT clients. They are not routable endpoints in Event Grid’s event routing pipeline. Because of this design, Topic Spaces can act as sources for routing messages out of MQTT (Device‑to‑Cloud), but they cannot be selected as destinations for Event Grid topic subscriptions. That is why you’re able to receive device‑to‑cloud messages in your backend service, but you cannot select a Topic Space as an endpoint to send cloud‑to‑device messages back to your MQTT clients. Event Grid routing currently supports routing MQTT messages outward to HTTP destinations and Azure services, but it doesn’t support reverse routing of events back into MQTT via topic subscriptions.

    Refer below points to resolve this issue or use them as workarounds:

    Use an MQTT client in the backend to publish directly to the device topic

    Your backend service can act as an MQTT publisher and connect to the Event Grid MQTT broker using a client identity that has publish permissions on the Topic Space. Publishing directly to the topic where the device is subscribed is fully supported and explains why your current MQTT client factory approach works. This approach requires maintaining an MQTT connection from the backend.

    Use the Event Grid MQTT HTTP Publish API (Recommended for C2D)

    Azure Event Grid provides an HTTP Publish API that allows backend services to publish messages into the MQTT broker without maintaining an MQTT connection. The backend sends an HTTP request targeting a topic that matches the Topic Space template, and Event Grid delivers the message to subscribed devices. The backend identity must have the EventGrid Topic Spaces Publisher role assigned. This is the recommended and supported Cloud‑to‑Device pattern when using Event Grid MQTT.

    Do not rely on Event Grid topic subscriptions for Cloud‑to‑Device MQTT flows

    Event Grid topics and subscriptions are designed for event routing out of MQTT, not into it. Topic Spaces will not appear as subscription endpoints, and this behavior is by design. Cloud‑to‑Device messaging must be implemented using MQTT publish or the HTTP Publish API instead of Event Grid topic subscriptions.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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