Skip to content
Stand with Ukraine flag

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.

  • 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.
TypeRequired fields
SAS TokensasKey (primary or secondary key); optional caCert
PEM CertificateClient cert + privateKey; optional caCert and key password

Exponential backoff with jitter for unacknowledged QoS 1 messages:

VariableDefault
TB_MQTT_CLIENT_RETRANSMISSION_MAX_ATTEMPTS3
TB_MQTT_CLIENT_RETRANSMISSION_INITIAL_DELAY_MILLIS5000
TB_MQTT_CLIENT_RETRANSMISSION_JITTER_FACTOR0.15
  1. Resolve the topic pattern from message data and metadata.
  2. Publish the message data to IoT Hub via MQTT with QoS 1.
  3. On acknowledgment: route via Success.
  4. On error: add error to metadata; route via Failure.
ConnectionCondition
SuccessMessage published and acknowledged by IoT Hub.
FailureAuthentication failure, retransmission exhausted, or unexpected error. Error details in metadata error key.

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.

{
"$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" }
}
}