Azure Event Hub Integration
Azure Event Hub Integration reads events from an Azure Event Hubs event hub, typically the built-in Event Hub-compatible endpoint of Azure IoT Hub. An uplink data converter transforms each event into device or asset data, including telemetry and attributes. For IoT Hub, ThingsBoard can also send downlink cloud-to-device messages to any device in the hub.
Use Azure Event Hub Integration when:
- Your devices already send device-to-cloud messages to Azure IoT Hub, and you want their telemetry in ThingsBoard.
- Your applications publish events to an Azure event hub.
- You need to send commands from ThingsBoard to IoT Hub devices as cloud-to-device messages.
Architecture
Section titled “Architecture”- Receive data. Devices send device-to-cloud messages to IoT Hub, which routes them to its built-in Event Hub-compatible endpoint. The integration reads every partition of that endpoint as a member of a consumer group.
- Decode the payload. The uplink converter identifies the target device or asset from the payload or the IoT Hub device that sent the message, and extracts attributes and telemetry.
- Process the message. ThingsBoard processes the converted data through the Rule Engine. If Allow create devices or assets is enabled, ThingsBoard can create an entity that does not exist yet.
- Send downlink data (optional). The Rule Engine passes a message to the integration. The downlink converter encodes it, and the integration sends it through the IoT Hub service API as a cloud-to-device message to the device in
metadata.deviceId.
Prerequisites
Section titled “Prerequisites”- Access to ThingsBoard Cloud with integrations enabled for your tenant.
- Permission to create integrations and data converters, and to edit rule chains for downlink.
- An Azure account with an active subscription and permission to create an IoT hub and register devices, or an Event Hubs namespace for a standalone event hub.
- The Azure CLI with the azure-iot extension to send test messages.
- Outbound TCP port
5671(AMQP) open from the ThingsBoard server (or the remote integration host) to Azure. Port443(HTTPS) is also needed if you store checkpoints in Azure Blob Storage.
Configure Azure IoT Hub
Section titled “Configure Azure IoT Hub”Create the hub, register a device, and copy the connection details of the built-in endpoint.
Create an IoT Hub
Section titled “Create an IoT Hub”- In the Azure portal, search for IoT Hub, open the IoT Hub service, and click + Create.
- On the Basics tab, select or create a Resource group, enter a globally unique IoT hub name (for example,
tb-iot-hub), choose a Region, and select a Tier. The Basic tier does not support cloud-to-device messages, so choose the Free or Standard tier. - Adjust the Networking and Management tabs if your environment requires it, then click Review + create and Create.
- When the deployment finishes, click Go to resource.
For tiers and limits, see Create an IoT hub.
Register a Device
Section titled “Register a Device”This guide registers a temperature sensor with the ID temp-sensor-02. Like most real devices, it sends only its measurements, so the decoder names the ThingsBoard device after the Azure Device ID of the sender. Both devices then have the same name, so downlinks reach the sensor without extra mapping.
- In the hub, go to Device management ⇾ Devices and click + Add Device.
- Enter the Device ID
temp-sensor-02. - Keep Authentication type set to Symmetric key and Auto-generate keys selected.
- Click Save.
Copy the Built-in Endpoint
Section titled “Copy the Built-in Endpoint”- In the hub, go to Hub settings ⇾ Message routing and open the Endpoints tab. Scroll down to Built-in endpoints.
- Expand Event Hub Details. Under Consumer Groups, enter
thingsboardin Create new consumer group and press Enter. Give each ThingsBoard integration its own consumer group: Azure allows one reader per partition in a consumer group, so two integrations, or an integration and another application, on the same group take the partitions from each other. - Expand Event Hub compatible endpoint. In Shared access policy, select
service. - Click the copy button of Event Hub-compatible endpoint. It is a connection string that ends in
EntityPath=<event hub name>.
The Shared access policy selects the key in the connection string. ThingsBoard reads events and sends downlinks with this key. The portal lists only policies with Service connect permission. Use service: it is enough for uplink and downlink. The default iothubowner also works, but it gives full control of the hub.
You now have the values for the integration:
| Value | Example | Source |
|---|---|---|
| Connection string | Endpoint=sb://… |
Event Hub-compatible endpoint in Built-in endpoints (Message routing ⇾ Endpoints), with the service policy |
| IoT Hub name | tb-iot-hub |
Hub name, as in tb-iot-hub.azure-devices.net. Not the Event Hub-compatible name (iothub-ehub-tb-iot-hub-…) on the same page. Needed only for downlink. |
| Consumer group | thingsboard |
Created in step 2. Default: $Default. |
Read a Standalone Event Hub (Optional)
Section titled “Read a Standalone Event Hub (Optional)”To read events that applications publish to an event hub, use the connection string of that event hub instead. Downlink is not available in this case.
- In the Azure portal, search for Event Hubs and click + Create. Select the Resource group, enter a Namespace name, for example
tb-eventhubs-01, select the Region, set Pricing tier to Standard and Throughput Units to1, and click Review + create, then Create. The Basic tier allows only the$Defaultconsumer group. When the deployment finishes, click Go to resource. - Click + Event Hub, enter a Name, for example
telemetry, set Partition count to2, and click Review + create, then Create. - Open the event hub and click + Consumer group. Enter
thingsboardand click Create. - Go to Settings ⇾ Shared access policies of the event hub, click + Add, enter a Policy name, for example
thingsboard, select Listen, and click Create. - Open the policy and click the copy button of Primary connection string. Keep Show AMQP connection strings cleared. The string ends in
EntityPath=telemetry.
In events from a standalone event hub, the converter metadata has no sysProp:iothub-connection-device-id, so the payload must carry the device name in deviceId.
Set Up Azure Event Hub Integration
Section titled “Set Up Azure Event Hub Integration”Create the uplink converter, assign it to a new Azure Event Hub integration, and send a test message as the device.
Create the Uplink Data Converter
Section titled “Create the Uplink Data Converter”The uplink converter receives each event body as a byte array, resolves the target device, and returns its telemetry and attributes. Azure Event Hub Integration uses the Generic converter: you write the decoder in TBEL or JavaScript. For converter types and the full decoder reference, see Uplink data converter.
-
Go to Integrations ⇾ Data converters and click + Add data converter ⇾ Create new converter.
-
Converter type — keep Uplink.
-
Integration type — select Azure Event Hub.
-
Name — enter a name, for example
Azure Event Hub Uplink Converter. -
Main decoding configuration — the editor opens with the default Azure Event Hub decoder, which is the decoder below. Keep it, or write your own. It takes the device name from
deviceIdin the payload or, for IoT Hub messages without it, from the Azure Device ID of the sender. It maps static device properties to attributes and all other top-level fields to telemetry. It also readstimestamp,location,vibration,metadata, andalarmswhen the payload carries them, and uses the server time when there is notimestamp. Atimestampthat cannot be parsed as a date rejects the message. The editor opens in TBEL; use the TBEL / JS toggle to switch to JavaScript./** Decoder **/// Decode the incoming payload to a JSON object.var data = decodeToJson(payload);// The device name comes from deviceId in the payload, for example when a gateway sends data of several devices.// Otherwise, it is the Azure IoT Hub device that sent the message (sysProp:iothub-connection-device-id).// Reject the message if neither is present.var deviceName = data.deviceId != null ? data.deviceId.toString().trim() : "";var senderId = metadata["sysProp:iothub-connection-device-id"];if (deviceName.isEmpty() && senderId != null) {deviceName = senderId.trim();}if (deviceName.isEmpty()) {raiseError("Payload has no deviceId and the message has no sysProp:iothub-connection-device-id");}// The device profile comes from deviceType. If it is missing or empty, the "default" profile is used.var deviceType = data.deviceType != null ? data.deviceType.toString().trim() : "";if (deviceType.isEmpty()) {deviceType = "default";}// Use the timestamp if provided; otherwise, use the current server time.// An invalid timestamp rejects the message.var ts = data.timestamp != null && !data.timestamp.toString().trim().isEmpty() ? new Date(data.timestamp).getTime() : Date.now();// Static device properties become attributes.var attributes = {};if (data.location != null) {attributes.latitude = data.location.latitude;attributes.longitude = data.location.longitude;attributes.altitude = data.location.altitude;}if (data.metadata != null) {attributes.version = data.metadata.version;attributes.manufacturer = data.metadata.manufacturer;}// All other top-level fields (temperature, pressure, status, humidity, ...) become telemetry as they are.var handled = ["deviceId", "deviceType", "timestamp", "location", "metadata", "vibration", "alarms"];var telemetry = {};foreach (key : data.keySet()) {if (!handled.contains(key)) {telemetry[key] = data[key];}}if (data.alarms != null) {telemetry.receivedAlarms = data.alarms;}if (data.vibration != null) {telemetry.vibrationX = data.vibration.x;telemetry.vibrationY = data.vibration.y;telemetry.vibrationZ = data.vibration.z;}if (data.metadata != null) {telemetry.batteryLevel = data.metadata.batteryLevel;telemetry.batteryStatus = data.metadata.batteryStatus;}// Return the converted uplink message.return {deviceName: deviceName,deviceType: deviceType,attributes: attributes,telemetry: {ts: ts,values: telemetry}};/** Decoder **/// Decode the incoming payload to a JSON object.var data = decodeToJson(payload);// The device name comes from deviceId in the payload, for example when a gateway sends data of several devices.// Otherwise, it is the Azure IoT Hub device that sent the message (sysProp:iothub-connection-device-id).// Reject the message if neither is present.var deviceName = data.deviceId != null ? String(data.deviceId).trim() : "";var senderId = metadata["sysProp:iothub-connection-device-id"];if (!deviceName && senderId) {deviceName = String(senderId).trim();}if (!deviceName) {throw new Error("Payload has no deviceId and the message has no sysProp:iothub-connection-device-id");}// The device profile comes from deviceType. If it is missing or empty, the "default" profile is used.var deviceType = data.deviceType != null ? String(data.deviceType).trim() : "";if (!deviceType) {deviceType = "default";}// Use the timestamp if provided; otherwise, use the current server time.// An invalid timestamp rejects the message.var ts = data.timestamp != null && String(data.timestamp).trim() !== "" ? new Date(data.timestamp).getTime() : Date.now();if (isNaN(ts)) {throw new Error("Invalid timestamp: " + data.timestamp);}// Static device properties become attributes.var attributes = {};if (data.location != null) {attributes.latitude = data.location.latitude;attributes.longitude = data.location.longitude;attributes.altitude = data.location.altitude;}if (data.metadata != null) {attributes.version = data.metadata.version;attributes.manufacturer = data.metadata.manufacturer;}// All other top-level fields (temperature, pressure, status, humidity, ...) become telemetry as they are.var handled = ["deviceId", "deviceType", "timestamp", "location", "metadata", "vibration", "alarms"];var telemetry = {};for (var key in data) {if (handled.indexOf(key) < 0) {telemetry[key] = data[key];}}if (data.alarms != null) {telemetry.receivedAlarms = data.alarms;}if (data.vibration != null) {telemetry.vibrationX = data.vibration.x;telemetry.vibrationY = data.vibration.y;telemetry.vibrationZ = data.vibration.z;}if (data.metadata != null) {telemetry.batteryLevel = data.metadata.batteryLevel;telemetry.batteryStatus = data.metadata.batteryStatus;}var result = {deviceName: deviceName,deviceType: deviceType,attributes: attributes,telemetry: {ts: ts,values: telemetry}};/** Helper functions **/// Convert the byte array to a string.function decodeToString(payload) {return String.fromCharCode.apply(String, payload);}// Convert the byte array to a JSON object.function decodeToJson(payload) {return JSON.parse(decodeToString(payload));}// Return the converted uplink message.return result;To adapt:
- Device name in another field — replace
data.deviceId, for example withdata.serialNumber. - Optional fields — remove the
location,vibration,alarms, ormetadatamappings your devices never send. - Fields that are not telemetry — add them to the list of handled keys (
handled), so they are not stored as telemetry. - Other device properties — add them to
attributesand to the list of handled keys, for exampleattributes.model = data.model;and"model"inhandled. - Update-only keys — for Azure Event Hub, ThingsBoard pre-fills the Update only keys list in Advanced decoding parameters with
manufacturer,receivedAlarms,status,batteryLevel,batteryStatus, andversion. These keys are stored only when their value changes. Edit the list to match your keys.
- Device name in another field — replace
-
Click Test decoder function and check the result (see Test the Decoder).
-
Click Add.
Decoder Inputs
The decoder signature is function decoder(payload, metadata): object | object[].
| Variable | Type | Content |
|---|---|---|
payload |
byte array | The event body. |
metadata |
{[key: string]: string} |
Each system property of the event as sysProp:<name>. For IoT Hub messages, this includes sysProp:iothub-connection-device-id (the sending device). For the time the event reached Azure, use sysProp:x-opt-enqueued-time (ISO 8601, UTC); sysProp:iothub-enqueuedtime is in the time zone of the ThingsBoard server. Also integrationName and the key–value pairs from the integration’s Metadata field. Application properties of the event, such as properties set by the device or added by IoT Hub message enrichments, are not passed. |
Built-in helpers:
| Function | Result |
|---|---|
decodeToJson(payload) |
Parses the bytes as JSON and returns an object. |
decodeToString(payload) |
Converts the bytes to a UTF-8 string. |
toFlatMap(obj, excludeList, pathInKey) |
TBEL only. Returns a flat key–value map of all values of obj, including nested ones, skipping the keys in excludeList at any level. With pathInKey set to true, keys are dot-separated paths, such as vibration.x; with false, only the last key is kept, so values with the same key overwrite each other. |
For field renaming, nested values, and non-JSON payloads, see Common scripting patterns.
Test the Decoder
Click Test decoder function below the editor. The dialog opens with a real IoT Hub message, the one temp-sensor-02 sends in this guide:
-
Payload content is the message body:
{"temperature": 31.7, "humidity": 41} -
Metadata holds the system properties of the message. The decoder uses
sysProp:iothub-connection-device-id:Key Value sysProp:iothub-connection-auth-generation-id639305923345763859sysProp:iothub-connection-auth-method{"scope":"device","type":"sas","issuer":"iothub"}sysProp:iothub-connection-device-idtemp-sensor-02sysProp:iothub-enqueuedtimeWed Nov 18 11:52:50 EET 2026sysProp:iothub-message-sourceTelemetrysysProp:x-opt-enqueued-time2026-11-18T09:52:50.139ZsysProp:x-opt-offset0sysProp:x-opt-sequence-number0sysProp:x-opt-sequence-number-epoch-1 -
Click Test. The Output panel shows:
{"deviceName": "temp-sensor-02","deviceType": "default","attributes": {},"telemetry": {"ts": 1795010624287,"values": {"temperature": 31.7,"humidity": 41}}}The message has no
timestamp, sotsis the current server time and differs in your test.
After the first real message, you can also open the converter Events, select the event, and test the decoder with its real payload and metadata, without typing them.
Check that deviceName is set and telemetry holds the expected keys. If the output is empty or shows an error, fix the decoder and test again.
Create the Integration
Section titled “Create the Integration”- Go to Integrations ⇾ Integrations and click + Add integration.
- Basic settings:
- Integration type — select Azure Event Hub.
- Name — keep the default
Azure Event Hub integrationor enter your own. - Enable integration and Allow create devices or assets — keep both on, so the device is created on its first uplink.
- Click Next.
- Uplink data converter:
- Click Select existing and choose
Azure Event Hub Uplink Converter. - Click Next.
- Click Select existing and choose
- Downlink data converter:
- Click Skip. Add a downlink converter later if you need to send cloud-to-device messages.
- Connection:
- Connection string — paste the Event Hub-compatible endpoint, or the Primary connection string of a standalone event hub.
- Consumer group — in Advanced settings, enter
thingsboard. Check the spelling: Azure accepts any name, so a typo silently reads with a separate consumer group. - Leave the other parameters at their defaults. See Connection Settings for details.
- Click Check connection. It checks that ThingsBoard can reach the event hub with this connection string. It does not check Consumer group.
- Click Add.
Connection Settings
Section titled “Connection Settings”| Parameter | Description |
|---|---|
| Connection string | Event Hubs connection string with EntityPath, for example the IoT Hub Event Hub-compatible endpoint. Required. |
| IoT Hub name | Name of the IoT hub, without .azure-devices.net, for example tb-iot-hub. Not the Event Hub-compatible name (iothub-ehub-…). Shown and required only when a downlink converter is assigned. ThingsBoard combines it with the key from Connection string to call the IoT Hub service API. Check connection does not check it: with a wrong name, downlinks are shown as sent but never reach the device. |
| Enable persistent checkpoints | Off by default: events sent while the integration is disabled or ThingsBoard is restarting are skipped. When on, the integration stores its position in Azure Blob Storage and resumes from the last checkpoint. See Persistent Checkpoints. |
| Execute remotely | Runs the integration as a separate process outside the ThingsBoard cluster. ThingsBoard generates an Integration key and Integration secret for it. See Remote Integration. |
Advanced settings
| Parameter | Default | Description |
|---|---|---|
| Connection timeout (sec) | 10 |
Timeout for each connection attempt, from 1 to 200 seconds. |
| Consumer group | $Default |
Consumer group the integration reads with. Use a dedicated group for each integration. Azure does not check that the group exists. Each group keeps its own position: switching back to a group used before reads events again from its older position, which can store some events twice. |
| Description | — | Free-text description. |
| Metadata | — | Key–value pairs added to the metadata of every message from this integration. |
Persistent Checkpoints
Section titled “Persistent Checkpoints”A checkpoint records the last event the integration processed in each partition. Without persistent checkpoints, the integration keeps them in memory, and events sent while it is disabled or ThingsBoard is restarting are skipped. With persistent checkpoints, it stores them in an Azure Blob Storage container and processes those events after a restart, as long as the hub still retains them (1 day on the IoT Hub Free tier, 1 hour by default for a new event hub in an Event Hubs namespace).
- In the Azure portal, click + Create a resource and select Storage account, or open an existing storage account and go to step 4.
- On the Basics tab, select the Resource group, enter a Storage account name (lowercase letters and digits), for example
tbcheckpoints01, select the Region of the hub, and set:- Primary service — Azure Blob Storage or Azure Data Lake Storage;
- Primary workload — General purpose;
- Performance — Standard;
- Redundancy — Locally redundant storage (LRS). The portal changes it to geo-redundant storage when you select the workload; LRS is enough for checkpoints.
- Click Review and create, then Create. When the deployment finishes, click Go to resource.
- Go to Security + networking ⇾ Access keys. Under key1, click Show next to Connection string, then click its copy button.
- Open the integration, click Toggle edit mode (pencil icon), and turn on Enable persistent checkpoints.
- Paste the connection string into Storage connection string.
- Enter a Container name, for example
tb-checkpoints. The integration creates the container if it does not exist. - Click Check connection, then Apply changes.
With persistent checkpoints on, Check connection also checks access to the container.
Test Uplink
Section titled “Test Uplink”Send a device-to-cloud message as the sensor temp-sensor-02, then confirm that ThingsBoard decoded it and created the device.
Send a Test Uplink
Section titled “Send a Test Uplink”The integration reads only events that arrive after it starts, so add the integration first. The message below has the same shape as the Microsoft device samples: measurements only, without a device ID or timestamp.
az iot device send-d2c-message \ --hub-name tb-iot-hub \ --device-id temp-sensor-02 \ --data '{"temperature": 31.7, "humidity": 41}'The command sends the message as the device, the same way device firmware does.
Verify the Result
Section titled “Verify the Result”- Integration events — go to Integrations ⇾ Integrations, open the integration, and click the Events tab. The uplink appears with status OK. Click
⋅⋅⋅in the Message column to see the event:systemProperties, includingiothub-connection-device-id=temp-sensor-02, andpayload. - Converter events — open
Azure Event Hub Uplink Converterin Integrations ⇾ Data converters and click the Events tab. In shows the received payload, Out shows the decoded result with"deviceName": "temp-sensor-02", and Metadata shows thesysProp:values and the integration name. - Device — go to Devices & assets ⇾ Devices. The integration has created temp-sensor-02 with the
defaultprofile. Open it and check the Latest telemetry tab fortemperature31.7andhumidity41.
Messages from other devices of the hub create their own ThingsBoard devices in the same way.
Configure Downlink
Section titled “Configure Downlink”ThingsBoard sends a downlink when the Rule Engine routes a message to the integration — for example, after a shared attribute update. The integration sends it through the IoT Hub service API as a cloud-to-device message to the Azure device in metadata.deviceId. IoT Hub queues the message until the device receives it or the message expires.
Downlink requires:
- An IoT hub as the event source. A standalone event hub has no cloud-to-device messaging.
- IoT Hub name in the integration.
- A Connection string whose policy has Service connect permission.
The downlink converter turns a Rule Engine message into the message body. For the full encoder reference, see Downlink data converter.
Create and Assign the Downlink Converter
Section titled “Create and Assign the Downlink Converter”The encoder returns:
contentType—JSON,TEXT, orBINARY.data— the message body.metadata—deviceId, the Azure Device ID of the target device. Required: without it, the integration skips the message. Everymetadatakey is also added to the message properties, together withcontent-type.
- Open the integration in Integrations ⇾ Integrations and click Toggle edit mode (pencil icon).
- In the Downlink data converter field, click Create new. The Downlink converter type and Azure Event Hub integration type are preselected.
- Enter a name, for example
Azure Event Hub Downlink Converter. - Main encoding configuration opens with the default Azure Event Hub encoder, which is the encoder below. Keep it, or write your own.
- The new converter records all debug messages for a limited time (the debug button shows the time left). When the time runs out, click the debug button, select All messages, and click Apply.
- Click Add.
- Enter the IoT Hub name: the name of the hub, shown at the top of its pages, for example
tb-iot-hub. Do not use the Event Hub-compatible name from Built-in endpoints (iothub-ehub-…). The field appears once a downlink converter is assigned. - Click Check connection, then Apply changes.
The default encoder:
/** Encoder **/
// Send the ThingsBoard message as JSON to an Azure IoT Hub device as a cloud-to-device message.// metadata.deviceId is the Azure Device ID of the target device; the integration skips messages without it.// This template uses the ThingsBoard device name as the Azure Device ID. Add it to the message metadata// with the "originator fields" rule node (Name -> deviceName).// The integration sends the message only when IoT Hub name is set in its connection settings.var deviceId = metadata.deviceName != null ? metadata.deviceName.trim() : null;if (deviceId == null || deviceId.isEmpty()) { raiseError("Message metadata has no deviceName");}
var result = { // Payload content type: JSON, TEXT, or BINARY (Base64). contentType: "JSON", data: JSON.stringify(msg), metadata: { deviceId: deviceId }};
return result;/** Encoder **/
// Send the ThingsBoard message as JSON to an Azure IoT Hub device as a cloud-to-device message.// metadata.deviceId is the Azure Device ID of the target device; the integration skips messages without it.// This template uses the ThingsBoard device name as the Azure Device ID. Add it to the message metadata// with the "originator fields" rule node (Name -> deviceName).// The integration sends the message only when IoT Hub name is set in its connection settings.var deviceId = typeof metadata.deviceName === "string" ? metadata.deviceName.trim() : "";if (!deviceId) { throw new Error("Message metadata has no deviceName");}
var result = { // Payload content type: JSON, TEXT, or BINARY (Base64). contentType: "JSON", data: JSON.stringify(msg), metadata: { deviceId: deviceId }};
return result;Without deviceName in the message metadata, the encoder stops with Message metadata has no deviceName, and the error is shown in the converter Events.
To check the encoder, click Test encoder function. The dialog opens with Message type ATTRIBUTES_UPDATED, Message {"temperatureUploadFrequency": 60}, and deviceName temp-sensor-02 in Metadata. Click Test. The Output shows:
{ "contentType": "JSON", "data": "{\"temperatureUploadFrequency\":60}", "metadata": { "deviceId": "temp-sensor-02" }}To adapt:
- Another envelope — build
datain the structure your device firmware expects, for example{ "method": "setConfig", "params": msg }. - Different Azure Device IDs — when ThingsBoard device names differ from Azure Device IDs, store the Azure ID in a device attribute and read it into
metadatawith an enrichment node. - Message properties — add keys to
metadata, for examplesource: 'thingsboard'. The device receives them as message properties. - Other message types — branch on
msgType, for example to handleRPC_CALL_FROM_SERVER_TO_DEVICEwithmsg.methodandmsg.params. See Rule Engine message types.
Configure the Root Rule Chain
Section titled “Configure the Root Rule Chain”The encoder reads deviceName from the message metadata, so the rule chain first adds the device name.
- Go to Data processing ⇾ Rule chains and open the Root Rule Chain.
- From the Enrichment section, drag an originator fields node onto the canvas.
- Enter a Name (for example,
Add device name) and map the source fields:- Name ⇾ deviceName
- Add mapped originator fields to ⇾ Metadata
- Click Add.
- Connect the message type switch node to the originator fields node with the Attributes Updated relation.
- From the Action section, drag an integration downlink node onto the canvas.
- Enter a Name (for example,
Downlink to Azure Event Hub), select your Azure Event Hub integration, and click Add. - Connect the originator fields node to the integration downlink node with the Success relation.
- Click Apply changes.
Test Downlink
Section titled “Test Downlink”- Go to Devices & assets ⇾ Devices, select temp-sensor-02, and open the Attributes tab.
- Select Shared attributes and click +.
- Set Key to
temperatureUploadFrequency, Type to Integer, Value to60, and click Add. ThingsBoard sends the downlink.
Verify the Downlink
Section titled “Verify the Downlink”-
Integration events — the integration’s Events tab shows a Downlink event with
deviceId(temp-sensor-02),payload({"temperatureUploadFrequency":60}), andproperties. -
Azure portal — in the hub, go to Device management ⇾ Devices. C2D messages queued of
temp-sensor-02is1until the device completes the message, then back to0. A connected device completes it at once, so the count often stays0. -
Device side — receive the message as the device:
Terminal window az iot device c2d-message receive --hub-name tb-iot-hub --device-id temp-sensor-02 --completeThe
datafield of the output is{"temperatureUploadFrequency":60}.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| Check connection fails with “Unable to connect. Check for correct Connection String!” | Wrong connection string, missing EntityPath, or blocked port 5671. |
Copy the Event Hub-compatible endpoint or Primary connection string again. Check that outbound TCP 5671 is open. |
| Uplinks stopped, the integration status is still Active and Events shows no error | The key in Connection string was regenerated in Azure, or the policy or event hub was deleted. ThingsBoard writes these errors only to the server log (“It was trouble when receiving: status-code: 401 …”). | Copy the connection string again and click Apply changes. Events sent in the meantime can be lost, especially in partitions that have no checkpoint yet. |
| No uplinks from IoT Hub, or only some of them, the hub has message routes | Messages that match a route to another endpoint do not reach the built-in endpoint. Messages that match no route reach it only while the fallback route is enabled. | Add a route with Endpoint events, and keep the fallback route enabled on the Message routing page. |
| Check connection fails with “…Check for correct Storage Connection String!” | Wrong storage connection string. | Copy it again from the storage account’s Access keys page. |
| No uplinks after a restart | Persistent checkpoints are off, so events sent while the integration was stopped are skipped. | Turn on persistent checkpoints. |
| No uplinks, connection is fine | Messages were sent before the integration started, or another reader takes the partitions in the same consumer group. | Send a new message. Use a dedicated Consumer group for each integration. |
| The same uplinks are stored twice | Consumer group was changed back to a group used before. Its stored position is older, so events already read are read again. | Keep the consumer group once it is set. |
| Device not created | deviceName is empty, or Allow create devices or assets is off. |
Check Out in the converter events and the integration settings. |
| No downlink is sent | The rule chain does not reach the integration downlink node, or the encoder does not set metadata.deviceId. |
Check the Root Rule Chain wiring. Check Out in the downlink converter events for deviceId. |
Downlink event is OK, the device receives nothing and C2D messages queued stays 0 |
IoT Hub name is wrong (for example, the Event Hub-compatible name), the Device ID does not exist in the hub, or the hub is on the Basic tier. ThingsBoard shows the downlink as OK even when Azure rejects it. | Enter the hub name in IoT Hub name. Compare deviceId with the device list. Use the Free or Standard tier. |
| Downlink queued, the device receives nothing | The message expired before the device connected. | Check Default TTL under Cloud to device messaging in Built-in endpoints (Hub settings ⇾ Message routing ⇾ Endpoints). |
To read debug events, open the integration or converter, click Events, and select an event: In is the received data, Out is the converter result, and Error holds the error text.
See Also
Section titled “See Also”- Integrations overview — how integrations, converters, uplinks, and downlinks fit together.
- Azure IoT Hub Integration — connect to IoT Hub over MQTT as one device.
- Uplink data converter — decoder inputs, output format, and scripting patterns.
- Downlink data converter — encoder reference.
- Remote Integration — run the integration outside the ThingsBoard cluster.
- TBEL — built-in functions and syntax for converter scripts.
- IoT Hub built-in endpoint — Event Hub-compatible endpoint, consumer groups, and retention.
- Cloud-to-device messages — delivery, expiration, and feedback.
Was this helpful?