Skip to content
Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

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.
Type Required fields
SAS Token sasKey (primary or secondary key); optional caCert
PEM Certificate Client cert + privateKey; optional caCert and key password

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
  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.
Connection Condition
Success Message published and acknowledged by IoT Hub.
Failure Authentication 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" }
}
}