What is the correct way to include MQTT topics in Message class

Pranav Sanghadia 6 Reputation points

I have developed an Azure IoT Edge module in Python which subscribes to MQTT messages from a device, this device is read only, means I can't login or change anything in the device except to receive messages using MQTT. I am sending the MQTT message received from the device to an output using send-message-to-output send_message_to_output(message, output_name) which in turn uploads it to Azure IoT Hub.

The message class takes MQTT Payload :

message = Message(MQTT_Payload) // Using message class

I tried sending MQTT topic in custom_properties of the message, it works. I can see the topic in Azure cloud shell using following command:

az iot hub monitor-events -n Intel-Hub1 --content-type application/json --properties app

Please note that I am not using MQTT to send message from IoT Edge to IoT Hub.


Am I doing the right thing? If not, what is the correct way to include MQTT Topic in "message" such that other Azure services like Azure TSItime-series-insights-overview can use the message easily? Appreciate if you can point me to relevant documentation or an example.
Is there any other approach?

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
534 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,113 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pranav Sanghadia 6 Reputation points

    I tried a simple method to constructed the message like this {"topic": {value}}. Following is the message on Azure Cloud Shell. I think Azure TSI seems to accept this payload format.

        "event": {
            "origin": "IntelGateway",
            "module": "PyModule",
            "interface": "",
            "component": "",
            "properties": {
                "application": {}
            "payload": {
                "N/304511aed4fa/solarcharger/256/Dc/0/Voltage": 46.5099983215332

    Please let me know if there is a better way of sending mqtt topic and value?

    1 person found this answer helpful.