Bosch IoT Device Management

Azure IoT Hub - AMQP connection

Send cloud-to-device messages to Azure IoT Hub devices.


In this example, we configure an AMQP connection that publishes live messages as cloud-to-device (C2D) messages to Azure IoT Hub.

Table of contents:

Prerequisites

To follow this example you will need:

  • A Bosch IoT Things service subscription

  • An Azure IoT Hub instance

  • An Azure IoT Hub device

Create the connection

Starting at the Bosch IoT Suite Console, click the Connection entry in the left navigation.

In case it is not there, use the search, and click the star icon to pin it to your navigation bar.


images/confluence/download/attachments/2232975794/connections-ui.png

Please make sure, that your connections are active. This is indicated with the plug symbol: in the example below the first connection is open and will work, the second one is disabled.

images/confluence/download/thumbnails/2232975794/connection-icons.png

If one of your connections are closed, just open them.

Click Add to create a new connection.

  • Select AMQP 1.0 from the categories.

  • Give the connection a name. Setting a name is required.

  • Click the Continue button.

images/confluence/download/attachments/1847337220/create-connection-amqp.PNG

Configure credentials

  • Scroll to the Coordinates section.

  • Choose hmac as the credential type.

  • Choose az-sasl as the algorithm.

  • Click the button Paste Azure IoT Hub connection string.
    Then paste the connection string of a shared access key with the service connect permission.

  • Enter the hostname of your Azure IoT Hub instance <iot-hub-name>.azure-devices.net.

images/confluence/download/attachments/1847337220/az-iot-hub-amqp-coordinates.PNG


The Time to Live field is the maximum duration a connection to IoT Hub stays open, before it is closed by Azure and needs to reconnect. It is recommended to leave it empty, or configure a high value, e.g. 168h (168 hours), to avoid frequent interruptions.

Add a target

  • Scroll to the Targets section.

  • Click the Add target button.

  • Enter /messages/devicebound as target address.

  • Add an authorization subject, e.g. integration:<solution-id>:az.

  • Check Thing live messages under Topics to publish on address.

  • Add header mappings:

    • iothub-ackfull

    • to/devices/{{thing:id}}/messages/devicebound

  • Click Save new target.

  • Click the Create button at the top right to save the connection.

images/confluence/download/attachments/1847337220/az-iot-hub-amqp-target.PNG

The connection is ready. Any live message the connection is authorized to receive is published to Azure IoT Hub as Cloud-to-Device message.

Note that the thing ID of the live message should be equal to the device ID in Azure IoT Hub.

Authorize the connection for messages

Follow the steps Add a policy entry for public cloud connections.

Replace xxx from that example with the authorization subject of this connection in the policy, e.g. integration:<solution-id>:az.