Skip to main content Skip to footer

Azure IoT Hub D2C Sender Documentation

Version: 4.2.2

Retrieved: 2025-10-09 15:15:44


Azure IoT Hub Device2Cloud

The module sends data to the Azure IoT Hub. It accepts text/binary data as input in the configured Source Property

Note

When using MQTT protocols only one connection per device ID is allowed by Azure. Therefore you cannot have two modules using the same credentials, eg Azure IoT Hub D2C and Azure Hub IoT C2D, or multiple instances of the same module. Either you have to use separate credentials with different device IDs or use HTTP as protocol.

Settings

Name Requirements Purpose Default
Source Property String with length 1-64 The property for which the file name(s) or data is found in data
Message Properties String with length 0-64 The property that contains the key/value pairs representing the message properties  
IoT Hub URI String with length 1-128 The URI of your IoT Hub  
Preferred Transport The preferred transport to use for communication, will fallback to others if primary fails MQTT, MQTT_over_Websocket, HTTP1, AMQP MQTT
Content Type String with lenght 0-64 the content type to set on the message application/json
Content Encoding String with lenght 0-64 the content encoding to set on the message UTF-8

Technical Note

Message properies are set as 'appProperties', ContentType and ContentEncoding are sent as 'systemProperties'

Credential

This module contains an option to select credentials to use in the module. All credentials supported by the module are presented in a drop-down.

Example: Connection string

If you have the following connection string

HostName=edgehubname.azure-devices.net;DeviceId=Crosser;SharedAccessKey=xyzxyzyz/ababcabc=

the data for the AzureDeviceCredentialModelWithSymmetricKey would be:

Device Key = xyzxyzyz/ababcabc=

Example: SAS Token

The SAS Token and id extracted from a full token connection string of

HostName=edgehubname.azure-devices.net;DeviceId=Crosser;SharedAccessSignature=SharedAccessSignature sig={signature-string}&se={expiry}&skn={policyName}&sr={URL-encoded-resourceURI}

would be

token1 = SharedAccessSignature sig={signature-string}&se={expiry}&skn={policyName}&sr={URL-encoded-resourceURI}

Device Id

Device Id in Azure for the specific credential.

IoT Hub URI

IoT Hub URI for your IoT Hub.

Input

To be able to successfully send data to the IoT Hub the message need to have a property matching the value of Source Property. The value property matching the Source Property name is expected to of type string or byte[].

Output

Output will be sent each time the module receives a message. The crosser object is added with status of the delivery to Azure

Name Type Description
crosser.success Boolean True if the message was successfully sent to IoT Hub, otherwise False
crosser.message String Contains an error message in case the communication failed, otherwise this property is not set.

Example - Send message to Azure IoT Hub

# Settings:
Source Property="content"
IoT Hub URI="crosserdemo.azure-devices.net"
Transport="MQTT"

# Incoming message:

{
    content: "Hello IoT Hub"
}

# Send to Azure IoT Hub:
"Hello IoT Hub"


# Outgoing message:

{
    content: "Hello IoT Hub",
    crosser:{
      success: true
    }
}

Example - Send message to Azure IoT Hub with Message Properties

# Settings:
Source Property="content"
Message Properties = "properties"
IoT Hub URI="crosserdemo.azure-devices.net"
Transport="MQTT"

# Incoming message:

{
    content: "Hello IoT Hub",
    properties: {
      "Table": "TestTable",
      "Format": "json",
      "IngestionMappingReference": "TestMapping",
      "IoTHubName": "TestHub",
    }
}

# Send to Azure IoT Hub:
"Hello IoT Hub"


# Outgoing message:

{
    content: "Hello IoT Hub",
    properties: {
      "Table": "TestTable",
      "Format": "json",
      "IngestionMappingReference": "TestMapping",
      "IoTHubName": "TestHub",
    }
    crosser:{
      success: true
    }
}