Skip to content

Azure Exporter Component

The Azure Exporter component uses the azure-iot-sdk-c libraries to provision and connect devices to the Azure IoT Hub for sending and receiving messages. The Azure Exporter component provides similar capabilities to the Azure Sphere Exporter component, as follows:

  • Exports data to and from Azure IoT Hub and Digital Twins
  • Subscribes to device data on multiple Bus topics, each of which correspond to a device
  • Publishes data to devices on multiple Bus topics, each of which correspond to a device
  • Supports Raw and Device data formats

Azure Exporter Pre-requisites

Before using the Azure Exporter component, complete the following steps:

  1. Create an IoT Hub. For further information on creating an IoT Hub, refer to the Create an IoT hub using the Azure portal section of the Azure documentation

  2. Create a Device Provisioning service. For further information on creating a Device Provisioning service, refer to the Create a new IoT Hub Device Provisioning Service section of the Azure documentation

  3. Link the IoT Hub with the Device Provisioning service. For further information on linking an IoT Hub with a Device Provisioning service, refer to the Link the IoT hub and your Device Provisioning Service section of the Azure documentation

  4. Generate the Root CA, intermediate, leaf(device) certificate and full-chain certificates for each device to be provisioned. For further information on creating the certificate chain, refer to the section Create an X.509 certificate chain

  5. In the Device Provisioning service, add the Root CA to Certificates and create a verification certificate to perform proof-of-possession as described in the section Verify ownership of the root certificate

  6. In the Azure portal, create a Group enrollment using the intermediate certificate as described in the section Create an enrollment group. For further information on managing device enrollments, refer to the How to manage device enrollments with Azure portal section of the Azure documentation

Note

The full-chain certificate, private key and device name used to generate certificates are used in the configuration for provisioning a device in the IoT Hub. The full-chain certificate can be found at ./certs/<mydevice>-full-chain.cert.pem and private key at private/<mydevice>.key.pem where mydevice is the name of the device used to create certificates.

Azure Exporter Configuration Variables

The following table describes the configuration variables that can be used with the Azure Exporter component:

Parameter Type Description Valid Values Required
Bus String The name of the Bus component to use The name of an existing Bus component Y
Logger String The name of the Logger component to use The name of an existing Logger component N
WorkPeriod Unsigned Integer The polling interval of the Azure Cloud in milliseconds Default 100 milliseconds N
ConnectionType Enum Specifies the device connection mechanism for connecting the device to the IoT Hub

Specify DPS to connect using the Device Provisioning service

Specify DAA to connect directly

Note: IOTech recommends that you use DPS.
Valid values are as follows:
  • DPS (default)
  • DAA
N
HostName String The host name of the Azure IoT Hub A valid host name for the Azure IoT Hub Y
DeviceID String The device identifier of the AzureSphere device A valid device ID Y
ScopeID String The scope identifier of the Azure Device Provisioning service A valid DPS scope ID Y
Devices Array An array of device configurations that are connected through the AzureSphere exporter to the Azure IoT Hub See Device Parameter Configuration Variables below Y
Certificate String Full-chain certificate of a device in PEM format Path and full name of certificate Y
Key String Private key of a device in PEM format Path and full name of key Y

Device Parameter Configuration Variables

The following table describes the configuration variables that can be used with the Azure Devices parameter:

Parameter Type Description Valid Values Required
Name String The device name A valid device name Y
Topic String The Bus topic on which the device publishes data A valid Bus topic name Y
Pattern String The Bus pattern on which the device receives updates A valid Bus pattern Y
Format Enum The default JSON encoding used for data sent to, or received from, the device Valid values are as follows:
  • Device
  • Raw (default)
N
TwinID String The IoT Hub digital twin identifier

Used to map data from a device to its digital twin

If not set, the value of the Name parameter is used as the twin identifier
A valid digital twin device ID N

Azure Exporter Configuration Example

The following example configures an Azure export component:

{
  "Bus": "bus",
  "Logger": "logger",
  "Cookie": 1234,
  "WorkPeriod": 100,
  "ConnectionType": "<DPS | Direct>",
  "HostName": "<Azure IoT Hub host name>",
  "DeviceID": "<Azure device id>",
  "ScopeID": "<Scope ID for IoT Hub provisioning service>",
  "Certificate": "<Full-chain certificate of a device in PEM format>",
  "Key": "<private key of a device in PEM format>",
  "Devices": [
    {
      "Name": "device-virtual",
      "Topic": "<Bus Topic on which the device publish data to Azure Cloud>",
      "Pattern": "<Bus Pattern on which the device receives data>",
      "Format": "Raw",
      "TwinID": "<Device twin id>"
    }]
}