3.12.3. Pre-Configured Connections

Because MQTT is a messaging protocol, not a data communications protocol, it does not specify a particular format for making a connection or the data payload. Thus, each MQTT implementation can be different with its own, unique connection characteristics.

Our Standard MQTT option provides a generic way to configure a connection to any MQTT broker. In addition, we offer the following pre-configured options to facilitate connecting to Azure, Google, or AWS MQTT brokers.

3.12.3.1. Azure IoT Hub

To make a connection to Azure IoT Hub you will need to follow some extra steps. A password must be generated by a separate tool as described below.

Once you have a password, click the Azure IoT Hub radio button and enter the following information:

IoT Hub Name

The IoT Hub Name provided by Azure.

Device Name

A name for the device that you want to connect.

Tell IoT Hub to treat messages as JSON text instead of binary.

By default Azure IoT Hub treats an MQTT payload as binary data. Selecting this option (the default) will inform IoT Hub that the payload is JSON text, typical of a DataHub MQTT client connection. This may affect how other downstream Azure services process the MQTT messages.

Subscribe to cloud-to-device events

Optionally, you can enter the MQTT message format to receive data and event updates from the IoT Hub.

After making your entries, press the Reconfigure button to add that configuration to the list, and clear the fields for another entry. You will see the necessary information entered in the Connection, Authentication, and Message Content tabs. You can optionally configure a Last Will Message, if desired.

[Note]

The Reconfigure button also sets the DataHub instance's Broker Limits configuration to the default values for this cloud service's broker. If any broker limits are non-zero, (such as if they were previously configured), they will not be reset. To reset them, first manually change them to zero and then click this button again.

When you are finished, you can configure your Exchange Data options.

[Note]

Azure IoT Hub does not allow a client application to subscribe to a topic. That is the way Azure is designed. It was never intended to be a general-purpose MQTT broker. The only way to get data from Azure via MQTT is through a mechanism called “Cloud-to-device events”. There is a setting in the DataHub configuration for that. You need to generate the events from the Azure portal. The Azure documentation can provide more information: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messaging.

CA Certificates

DataHub software supports CA certificates for SSL, in either PEM or PFX format. To use a CA certificate you need to do the following in your Azure IoT Hub configuration :

  1. Go to Certificates and add your CA certificate.

  2. Create your device and set the Authentication type to authenticate by Certificate.

Then, in the DataHub MQTT Client Azure IoT Hub Authentication tab:

  1. Check the Use SSL box.

  2. Add your CA signed client certificate in the Client Certificate field.

Azure IoT Password Creation

The Azure IoT password is an SAS token. To generate the SAS token:

  1. Open your IoT Hub in the Azure portal.

  2. On the left menu under Settings find the Shared Access Policies, and click on the policy you want to use.

    On the right you will see the Shared Access Keys.

  3. Find and make a copy of the Connection-String Primary. You will need this in the Azure IoT Explorer.

  4. Download the current release of the Azure IoT Explorer from:

    https://github.com/Azure/azure-iot-explorer/releases

  5. Install it and run the application.

  6. Paste in the copy you made of the IoT Hub Connection String Primary, and click Connect.

    This will list your IoT Devices.

  7. Click your device.

  8. Find the Connection string with SAS Token section.

  9. Set Symmetric Key to Primary Key.

  10. Set the keys expiration time in minutes.

  11. Click Generate. The result will look like this:

    HostName=SWTBOPCUAHub.azure-devices.net;DeviceId=TestDevice2;
    SharedAccessSignature=SharedAccessSignature sr=SWTBOPCUAHub.az
    ure-devices.net%2Fdevices%2FTestDevice2&sig=FLwubhFB4V%2F7j6pZ
    S3KXEomL4%2F2uCaBSipyKiIZCWuw%3D&se=1592419771

    (But all one string, no carriage returns.)

  12. Azure only requires the part of this string starting from "SharedAccessSignature=". You can copy the entire string, or only the portion starting from "SharedAccessSignature=" to the end of the string. If you plan to share this configuration with older versions of the DataHub program then you should copy only that portion. The result should be a single string, similar to this:

    SharedAccessSignature sr=SWTBOPCUAHub.azure-devices.net%2Fdevi
    ces%2FTestDevice2&sig=FLwubhFB4V%2F7j6pZS3KXEomL4%2F2uBaCSipyK
    iIZCWuw%3D&se=1592419771

    (All one string, no carriage returns.)

This is the SAS token, which you can paste verbatim into the DataHub configuration Password field.