Connect to IoTHub with MQTT

GMAPRO 20 Reputation points
2025-03-17T18:41:33.7966667+00:00

For a direct connection between a device and IoT Hub, using MQTT, what should be the Server Name/IP parameter?

This information is not available in the manual:

https://learn.microsoft.com/pt-br/azure/iot/iot-mqtt-connect-to-iot-hub#connecting-to-iot-hub

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,258 questions
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 36,131 Reputation points MVP
    2025-03-17T21:18:53.5766667+00:00

    Hello @GMAPRO,

    welcome to this moderated Azure community forum.

    The Azure IoT Hub supports MQTT as communication protocol. It does not support full MQTT broker abilities like the EventGrid Namespace MQTT broker but uses it for the Device twin features.

    Check out this blog post where C# is used to connect via MQTT. or Python.

    These are making use of the device SDK.

    If you connect directly, use the 'public device endpoint'.

    This is probably the hostname '[iot hub name].azure-devices.net'.

    I have not used this way to communicate with the IoT Hub but connecting to the EventGrid Namespace MQTT broker works with the same kind of hostname as seen in this Nanoframework example.


    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.

    0 comments No comments

0 additional answers

Sort by: Most 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.