How-To Guides
...
Integration Guides
Azure IoT Hub Guides

Receive Data from Azure IoT Hub with a Device Certificate

8min

Review the following guide for setting up an inbound data integration between Litmus Edge and Azure IoT Hub using a Device Certificate.

Additional Resources

Refer to the following resources for more information.

Note: Integration does not support wildcard characters for inbound messages.

Before You Begin

You must first Set up an Azure IoT Hub. When you add the IoT device to the hub, select X.509 Self-Signed as the Authentication type when you add the IoT device in Azure.

Step 1: Retrieve Connector Parameters

You will need to log in to Azure to retrieve the parameters for configuring the connector in Litmus Edge.

Tip: Use the following command to generate a public/private key pair:

openssl req -newkey rsa:2048 -nodes -keyout myprivatekey.pem -x509 -days 365 -out mydevicekeycer.pem

To retrieve the connector parameters:

  1. From the Microsoft Azure home page, click your IoT Hub.
  2. From the Navigation panel under Explorers, click IoT devices.
  3. From the Azure IoT devices pane, copy the device name from the Device ID column.
  4. Click the Device ID for the device you want to connect.
  5. Copy the key ID and paste it to the Primary Thumbprint field, and then copy the certificate ID and paste it to the Secondary Thumbprint field.

Step 2: Add the Azure IoT Hub using Device Certificates Connector

Follow the steps to Add a Connector and select the MQTT - Azure IoT Hub using Device Certificates provider.

Configure the following parameters.

  • Name: Enter a name the connector.
  • Hostname: IP Address or Server FQDN of MQTT broker. 
  • Port: Verify the default value of 8883 is entered.
  • Device ID: Copy the Device ID retrieved in Step 1.
  • Certificate: Paste the certificate from the mydevicekeycer.pem file generated in Step 1.
  • Private key: Paste the key certificate from the myprivatekey.pem file generated in Step 1.
  • Parallel Publish Count: The maximum number of concurrently published messages. The default value is 16.
  • Integration Topic: The default topic to publish or subscribe to.
  • Token TTL: The token expiry time in minutes. The default value is 1440.
  • LWT Topic: The topic for MQTT's Last Will and Testament feature.
  • LWT payload: The payload for MQTT's Last Will and Testament feature.
  • LWT payload type: The payload type for MQTT's Last Will and Testament feature. The options are string and base64.
  • LWT QoS: The Quality of Service value for MQTT's Last Will and Testament feature.
  • LWT retained: Select this check box to retain the value for MQTT's Last Will and Testament feature.
  • Throttling Limit: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.
  • Persistent storage: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Litmus Edge when cloud providers are online.
  • Queue Mode: Select the queue mode as lifo (last in first out) or fifo (first in first out). Selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first.

Step 3: Enable the Connector

After adding the connector, click the toggle in the connector tile to enable it.

Document image


If you see a Failed status, you can review the Connector Logs and relevant error messages.

Step 4: Create Inbound Topics for Connector

You will now need to create inbound topics to receive data from Azure IoT Hub.

To create topics:

  1. Click the connector tile. The connector Dashboard appears.
  2. Click the Topics tab.
  3. Add topics to the connector with the details below. See the Add a Topic to a Connector section in Manage Connectors for more information.
    • Data Direction: Select Remote to Local - Inbound.
    • Local Data Topic: Enter integration.raw.inboundtest.
    • Remote Data Topic: Replace devices/[Device ID]/messages/events/ with devices/[Device ID]/messages/devicebound/%24.to=%2Fdevices%2Fmessages%2Fdevicebound. Replace [Device ID] with the Device ID value configured for the connector.
    • Enable: Click the toggle to enable the topic.
  4. Click Yes to add the topic.
  5. After adding all required topics, navigate to the Integration pane.
  6. From the connector tile, ensure the connector is not disabled and still shows a CONNECTED status.

Step 5: Initiate and View Inbound Messages

You will need to create a flow to view the inbound messages from the connector.

To initiate and view inbound messages:

  1. Follow the steps to Create a Flow and add the following nodes.
    • DataHub Subscribe:
    • Debug
  2. Double-click the DataHub Subscribe node. The Edit DataHub Subscribe node dialog box appears.
  3. Enter Azure inbound in the Name field.
  4. Paste the Topic you created in Step 4 in the Topic field.
  5. If needed, configure the Datahub Subscribe connection. See the "Step 3: Configure Connector Nodes" section in Create a Flow to learn more.
  6. Click Done, and then click Deploy.
  7. Click the debug tab.
  8. Log in to Azure.
  9. Open the device pane and click Message to Device. The Message to device pane appears.
  10. Enter Test Message in the Message Body field and click Send Message.
  11. Open the flow you created in Litmus Edge and check the Debug messages tab. See the Additional Options section in Manage the Flow Canvas for more details.
  12. Verify that Test Message appears in the debug results.