SAS Token Authentication

While the X.509 CA Certificate Authentication method is the recommended way of authenticating to Azure IoT Hub, SAS Token Authentication is an alternative method. This document describes how to set up the connection to the Azure IoT Hub using this authentication method .

To use SAS Token Authentication method, first, a device needs to be created in the Azure IoT Hub and a SAS Token needs to be generated for that device. Then the Cloud Sink object has to be configured so that it uses the generated SAS Token to connect to Azure IoT Hub.

Requirements

  • Azure account with a valid subscription and all the necessary permissions to add and manage resources. There also should be at least one Resource Group. More information about Resource Groups is available on the official Microsoft Documentation webpage.

  • access to an IoT Hub. The configuration of a sample IoT Hub for testing purposes is described here.

  • an IoT Device in the aforementioned Azure IoT Hub, with SAS Token Authentication configured.This page addresses how to create such a device, where to set or find the Device ID and how to generate a SAS Token.

  • The Device ID and a generated SAS Token for the aforementioned IoT Device.

  • The DigiCert Baltimore Root certificate file

Cloud Sink Configuration

1 Create a new Cloud Sink object in the I/O Model.

2 Select the Cloud Sink object.

3 In the Object Lens, expand the Configuration compound and select MQTT Publisher Interface.

4 In the MQTT Publisher Parameters property compound, for the Topic property, enter a string following this pattern:

devices/<DEVICEID>/messages/events/

where <DEVICEID> refers to the Device ID of the IoT Device. In this example, 'devices/indevice/messages/events/' is used.

5 Expand the Connection Parameters property compound, enter the following values for the parameters:

  • For the Broker Address property, enter a string, following this pattern:

    <HUBNAME>.azure-devices.net

    where <HUBNAME> is the name of your Azure IoT Hub.
    In this example, 'inmationMqttTest.azure-devices.net' is used.

  • Set the Broker Port to 8883

  • For the Client ID property, enter the Device ID of the IoT Device. In this example, 'indevice' is used.

6 Expand the Credentials property compound, configure the parameters as follows:

  • For the [.property]#Username property, enter a string following this pattern

    <HUBNAME>.azure-devices.net/<DEVICEID>/?api-version=2018-06-30

    where <HUBNAME> is the name of your Azure IoT Hub and <DEVICEID> refers to the Device ID.
    In this example, 'inmationMqttTest.azure-devices.net/indevice/?api-version=2018-06-30' is used.

  • For the Password property, enter the SAS Token for the IoT Device. In this example the following SAS Token is used:

    SharedAccessSignaturesr=inmationMqttTest.azure-devices.net%2Fdevices%2Findevice&sig=X%2B3r3iqIOu%2B9jPkmcy7pJ496RiPL8scvplo9A%2F18g2k%3D&se=1572964996

7

Expand the SSL/TLS Support property compound and import the DigiCert Baltimore Root certificate mentioned in the Requirements section.:

  1. Click import-solid Icon for the Certificate Authority property.

  2. Select the 'certs.cer' file.

  3. Click Open in the file dialog to import the certificate.

If everything is done correctly, it should be possible to view certificate details by clicking eye-solid Icon.

8 Click Apply in the Object Lens to save configuration.

Checking Functionality

You can now check the functionality of the Cloud Sink object.