skip to Main Content

When sending telemetry messages from a device to the following MQTT topic:

devices/<MY_DEVICE>/messages/events/%24.uid=<MY_UID>&%24.ct=application%2Fjson&%24.ce=utf-8&%24.ctime=<SOME_TIME>

With actual values for <...> and routing them to a service bus topic I can retrieve them using the Azure Python SDK which spits out instances of azure.servicebus.ServiceBusReceivedMessage (see the documentation).

These object contain most of the information I’m interested in, e.g. content_type is correctly set to "application/json" and application_properties contains iothub-connection-device-id and iothub-creation-time-utc. However there seems to be no way to access:

  • user-id
  • content-encoding
  • Something like iothub-message-source that indicates that this is a telemetry message.

This seems very strange to me, if this is not possible in general that would mean a backend application had no way of knowing what IoT Hub a telemetry message comes from, how it is encoded or that it is telemetry at all (and not say, a device twin change message), making the SDK almost useless.

Is there information I am missing?

2

Answers


  1. Unfortunately, the Azure Python SDK currently lacks direct access to some essential properties like user-id, content-encoding, and iothub-message-source, which can be crucial for identifying telemetry messages and their sources accurately. This limitation can indeed pose challenges for backend applications in distinguishing between different types of messages and their origins. You may want to explore alternative approaches or contact Azure support for any updates on this matter.

    Login or Signup to reply.
  2. The available system properties for routing configuration are listed here in MSDOC .

    Below are the message properties which are triggered in linked service bus from IoT hub.

    enter image description here

    Note: Refer MSDOC to check the available service bus message properties.

    For contentEncoding, the user specifies the encoding type of the message. If the contentType property is set to application/JSON, then allowed values are UTF-8, UTF-16, and UTF-32.

    iothub-message-source is the event category that identifies the message source, such as deviceLifecycleEvents .
    Refer this github for more relevant information.

    The user-id is user-settable and is the name of the IoT Hub that generated the event.

    I tried to send/route the data to Event Hub, and according to this document

    Note:

    According to this MSDOC,
    The properties will only be populated for events that have been read from Event Hubs. The default value when not populated is an empty set.

    By referring to this MSDOC ,I tried to receive events using Azure Event Hubs as shown below.

    Event From Iot Hub:
    enter image description here

    Event from Event Hubs:
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search