An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
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.