Table of Contents
Cloud Connector Azure IoT Hub Message Transformation
Since Azure is not a fully fledged MQTT broker, Cloud Connector needs to transform messages coming from standard topics to the topics and messages format that IoT Hub is expecting.
Cloud Connector will transform 3 types of messages with the topic and authentication part of the MQTT message to match what Azure is expecting.
Let’s assume we have a device and endpoint with the following values:
Azure IoT Host: my-iot-hub-name.azure-devices.net
Device Cloud ID: 4601234567890
CONNECT Message
Incoming message:
hasUsername: false
username: someUsername
clientIdentifier: someClientIdentifier
Sent to Azure as:
hasUsername: true
username: my-iot-hub-name.azure-devices.net/4601234567890
clientIdentifier: 4601234567890
Note: Cloud Connector is only modifying three fields hasUsername
, username
and clientIdentifier
, all other fields are sent as they are.
PUBLISH Message
Incoming message:
topic: /my/desired/topic
payload: {"someField":"Some data I want to send"}
Sent to Azure as:
topic: devices/4601234567890/messages/events/my-desired-topic
payload: {"someField":"Some data I want to send"}
Cloud Connector is prepending the only topic format that Azure allows from the incoming topic replaces any /
with -
and then publishes the message to a property_bag
called my-desired-topic
under that device in IoT Hub.
Note: Cloud Connector is only modifying one field topic
, all other fields are sent as they are.
SUBSCRIBE Message
Incoming message:
topics: /my/desired/topic, /topic/with/wildcard/#
Sent to Azure as:
topics: devices/4601234567890/messages/devicebound/my-desired-topic, devices/4601234567890/messages/devicebound/#
Subscribe messages have 2 conditions:
- When a topic has multi levels like
/my/desired/topic
, Cloud Connector will transform the same way as publish message but this time to thedevicebound
topic in IoT Hub - If subscription topics contains a wildcard (
#
), Cloud Connector removes anything else from the topic and leaving the wildcard, ending up listening to anyproperty_bags
coming to that device.
Note: Cloud Connector is only modifying the topic
field, all other fields are sent as they are.