Robotron Datenbank-Software GmbH Firmenlogo
MIT DATEN MEHR BEWEGEN.
🇩🇪 🇬🇧

Azure IoT Hub

The Azure IoT Hub module is used to send messages to an Azure IoT Hub.

Incoming messages are collected by the module and written to a buffer. Every 2.5 seconds, the buffered messages are bundled and sent to the IoT Hub, and the buffer is cleared. In addition, data compression is available. Before sending, the batch size is checked. If it exceeds 256 KB, the batch is split. These split batches are sent every 0.5 seconds. The timeout for sending is set to 5 seconds.

Furthermore, it is possible to configure functions for Cloud2Device communication.

Configuration Parameters

Connection

To connect to the Azure IoT Hub, the parameters described in the following table must be configured.

Table 1. Configuration of the Connection for the Azure IoT Hub Module
ParameterDescription

Device Connection
String

Access path and authentication of the device at the corresponding IoT Hub.

This can be found in the created device of the IoT Hub in the Azure Portal [1] under Menu (top left) → All Services → IoT Hub. Selecting IoT Hub leads to Explore IoT Devices. The corresponding device must be selected and the Connection String (Primary Key) copied.

Proxy

The use of a proxy for the connection between the device and the Azure IoT Hub is optional.

Protocol

The following protocols are supported for data transfer to the Azure IoT Hub:

  • MQTT (default)

  • HTTP

  • AMQP

Compression

Compression of telemetry messages before sending is possible using Deflate or GZip.

  • Deflate: Data compression using the Deflate algorithm

  • GZip: Data compression using the GZip algorithm

The grouped display for the Connection String Info shows metadata from the Device Connection String. It is important to pay attention to the "isValid" indicator here.

When using the HTTP protocol, Cloud2Device communication (see Permissions) is not available. This means:

  • No TWIN updates

  • No Cloud2Device Messages

  • No Direct Method Calls

Permissions

It is possible to allow Cloud2Device communication with the Azure IoT Hub using the following configuration options:

Receive Cloud Messages

Allows receiving Cloud Messages.

Receive Configuration from Desired Properties

Allows processing of Desired Property Updates of the Device Twin. The HTTP protocol is not available for this option.

Submit Message Headers as Azure Message Properties

Edge Message Headers are transmitted as Message Properties.

Send ModuleStatus to Reported Properties

Allows sending the module status to the Reported Properties of the Device Twin. The HTTP protocol is not available for this option.

Messages / Topics

Topics are logical instances in which related messages are collected and processed. Topics can be created for different data categories/purposes, which are described in Table 2.

To collect and process the messages of an input module, specifically the input topics of an input module, the name of the desired input topic must be defined in the Azure IoT Hub module as a "New Topic" or "Output Topic".

Table 2. Topics in the Azure IoT Hub
CategoryDescription

Telemetry Messages

New topics can be added by entering the topic name and clicking "+". Afterwards, the data input module whose data is to be evaluated must be defined.

Cloud2Device Messages (optional)

The output topic defines under which topic incoming Cloud Messages are published.

Direct Methods

The methods can be called via Azure. The name of the Direct Method can be entered in the local RoboGate Edge UI. A mapping is made between the Azure Direct Method and the Edge Method.

Blob Upload

The IoT Hub offers the option to store larger amounts of data in a connected Azure Blob Storage. Incoming messages are stored as files in the Blob Storage. The name and storage location can be defined using a pattern.

A specific pattern must be specified for the Blob Upload. The following overview can be used as a reference.

Default Pattern: {prefix}{ticks}
Folder Separator: /

Table 3. Pattern Overview
VariableContent Default

{year}

Current UTC Year (4 Digits)

{month}

Current UTC Month (2 Digits)

{day}

Current UTC Day (2 Digits)

{hour}

Current UTC 24h Hour (2 Digits)

{minute}

Current UTC Minute (2 Digits)

{second}

Current UTC Second (2 Digits)

{ticks}

Count of 100ns Intervals since 0001-01-01 00:00:00 UTC (64-bit number)

{prefix}

Edge Message Header prefix

{name}

Edge Message Header name

{ext}

Edge Message Header ext
(default blob)

{hub}

IoT Hub Name

{host}

IoT Hub DeviceId

{Source}

Edge Message Header Source
(default any)

{scope}

Edge Message Header scope
(default any)

Device Provisioning (DPS)

To achieve provisioning without configuring the IoT Hub or without factory-side configuration, Azure offers the Device Provisioning Service. DPS enables scalable and secure provisioning of multiple RoboGate Edge devices.

For DPS to be used, the "Device Connection String" in the connection configuration must be empty. The connection string is then obtained from DPS. For this to be provided, at least two settings of the following DPS configuration must be specified:

  • Scope

  • EnrollmentType (type of provisioning)

Table 4. Configuration of the Device Provisioning Service (DPS)
CategoryDescription

Scope ID

Defines the DPS ID scope. This setting must be provided. It must be obtained from Azure. (ID scope)

Mode

EnrollmentType:

  • Group: Applies to a group provisioning. The PrimaryKeyBase64 must be provided, as it is used for authentication. This symmetric key is generated by Azure and can be obtained from there.

  • Individual: Applies to individual provisioning. If provisioning is performed here without specifying the "PrimaryKeyBase64", this key must first be derived from the device (serial number / device ID). This can be done using the Edge method "robogate.dps.hash". The Base64 key generated there must then be entered in Azure. In addition, the device ID must be specified in Azure, as the Primary Key is linked to the device ID when retrieving the IoT Hub. The device ID can be retrieved using "robogate.security.GetClientId".

ID

The ID is to be specified as follows:

  • Group, optional, freely selectable

  • Individual, optional (device ID)

Symmetric Key (base64)

This is a key for authenticating the device. Depending on the registration provisioning configuration, this key can be omitted, as it is generated automatically (see Enrollment Type: Individual).

Advanced settings

Endpoint (URL) for the DPS. If this is not provided, the default endpoint is used.

Configuration in the UI

After selecting the Azure IoT Hub module on the home page or via the left menu bar of the RoboGate Edge UI, a connection to an Azure IoT Hub can be configured by clicking "New".

Configuring the Connection

In the first step, the connection must be configured with respect to the parameters described above. New topics for evaluating data from the input modules can be added by clicking "+". As an example, the output topic "Modbus_1" is entered in Figure 1.

azure topicmb
Figure 1. Adding a new topic Modbus_1

After completing the configuration of the Azure IoT Hub, it can be saved save (Figure 2). By saving the module configuration, the data of the selected topics is sent to Microsoft Azure and is available for evaluation in the IoT Hub.

azure save
Figure 2. Saving the configuration of the Azure IoT Hub module

In the "Module State" section, it can be seen whether the module was able to establish a connection to Azure.

Deleting a Topic

Topics can be removed from the configuration of the Azure IoT Hub module. To do this, the cross close behind the topic to be deleted must be clicked. This deletes the marked row (Figure 3). By subsequently clicking the save button save, the changed configuration is applied.

azure delete topic
Figure 3. Deleting an Azure IoT Hub Topic

Resetting the Configuration

The button reset in the horizontal menu bar can be used to reset the entire module configuration to factory settings. After clicking the button, a confirmation dialog with "Yes" and "No" appears, asking whether the operation should actually be executed.

This also deletes the entire history on the RoboGate Edge!