Azure IoT Hub
Use this node to publish messages to Azure IoT Hub via MQTT — for example, forwarding device telemetry collected in ThingsBoard to an Azure IoT Hub for processing by Azure Stream Analytics, or sending device-to-cloud messages to trigger Azure Functions.
Configuration
Section titled “Configuration”- Topic pattern — MQTT topic. Default:
devices/{clientId}/messages/events/. Supports templatization. - Host — Azure IoT Hub hostname:
{iot-hub-name}.azure-devices.net. - Client ID — the device ID as registered in Azure IoT Hub.
Credentials
Section titled “Credentials”| Type | Required fields |
|---|---|
| SAS Token | sasKey (primary or secondary key); optional caCert |
| PEM Certificate | Client cert + privateKey; optional caCert and key password |
MQTT retransmission
Section titled “MQTT retransmission”Exponential backoff with jitter for unacknowledged QoS 1 messages:
| Variable | Default |
|---|---|
TB_MQTT_CLIENT_RETRANSMISSION_MAX_ATTEMPTS | 3 |
TB_MQTT_CLIENT_RETRANSMISSION_INITIAL_DELAY_MILLIS | 5000 |
TB_MQTT_CLIENT_RETRANSMISSION_JITTER_FACTOR | 0.15 |
Message processing algorithm
Section titled “Message processing algorithm”- Resolve the topic pattern from message data and metadata.
- Publish the message data to IoT Hub via MQTT with QoS 1.
- On acknowledgment: route via
Success. - On error: add
errorto metadata; route viaFailure.
Output connections
Section titled “Output connections”| Connection | Condition |
|---|---|
Success | Message published and acknowledged by IoT Hub. |
Failure | Authentication failure, retransmission exhausted, or unexpected error. Error details in metadata error key. |
Examples
Section titled “Examples”Example 1 — Forward telemetry to IoT Hub
Section titled “Example 1 — Forward telemetry to IoT Hub”Data: { "temperature": 22.5, "humidity": 65 }.
{ "topicPattern": "devices/sensor-001/messages/events/", "host": "my-hub.azure-devices.net", "clientId": "sensor-001", "credentials": { "type": "sas", "sasKey": "base64encodedKey==" }}Result: message published to IoT Hub. Routes via Success.
JSON schema
Section titled “JSON schema”{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "TbAzureIotHubNodeConfiguration", "type": "object", "required": ["topicPattern", "host", "clientId", "credentials"], "additionalProperties": false, "properties": { "topicPattern": { "type": "string" }, "host": { "type": "string" }, "clientId": { "type": "string" }, "connectTimeoutSec": { "type": "integer" }, "credentials": { "type": "object" } }}