Brendan Thorpe
Brendan Thorpe

Reputation: 78

How do you set Azure IoT Hub "System Properties" using native MQTT?

I'm using native MQTT with an Azure IoT Hub. The underlying issue is that once the payload is routed to a blob storage it is encoded as Base64. I believe this is due to missing the System Property "contentType=UTF-8".

I tried using the following topics with no success:

devices/test/messages/events/contentEncoding=UTF-8&contentType=application/json
devices/test/messages/events/contentEncoding=UTF-8
devices/test/messages/events/contentEncoding=UTF-8&contentType=applicationjson
devices/test/messages/events/.contentEncoding=UTF-8

This put these two items into a "Properties" nest which is independent of the "System Properties" nest (see below).

{"EnqueuedTimeUtc":"2019-07-31T19:24:57.4290000Z","Properties":{"contentEncoding":"UTF-8","contentType":"applicationjson"},"SystemProperties":{"connectionDeviceId":"test","connectionAuthMethod":"{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}","connectionDeviceGenerationId":"000","enqueuedTime":"2019-07-31T19:24:57.4290000Z"},"Body":"msginbase64insteadofutf8"}

I tried formatting the message according to the "Common Format" described here also with no success: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-routing-query-syntax#message-routing-query-based-on-message-properties

Upvotes: 2

Views: 1597

Answers (1)

Roman Kiss
Roman Kiss

Reputation: 8235

The following is an example of the publisher topic and system properties*:

devices/test/messages/events/$.ct=application%2Fjson&$.ce=utf-8

Upvotes: 3

Related Questions