Skip to main content
Version: 1.8.5

CREATING A MICROSOFT AZURE CONNECTION

The Azure IoT Hub connector sends the uplinks of your devices to an Azure IoT hub, as device-to-cloud telemetry messages, and receives the downlinks of the devices as cloud-to-device messages. It connects to the IoT hub with the AMQPS protocol. Each device is a device of the IoT hub, identified by its DevEUI in uppercase.

The data follows this path: LoRaWAN® device → ThingPark Enterprise → ThingPark X IoT Flow connection → Azure IoT Hub.

Before you create the connection, you need an Azure IoT hub, on a free or a paid subscription. This page gives a minimal setup example. Check Azure IoT Hub pricing and IoT Hub limits to decide which subscription fits your needs.

Important note

If you plan to manage more than 65,500 devices, please consider migrating to Azure Event Hubs. Its architecture is more suitable for a large number of devices. Use one exclusive connection per IoT Hub when downlinks are required. If several connections must share the same IoT Hub, disable exclusive mode on all but one of them. See Azure limitations.

Creating an Azure IoT Hub​

  1. Go to the Azure Portal.

  2. Click Create a resource. Create a resource in the Azure portal

  3. Search for and select IoT Hub. Select IoT Hub

  4. Click Create. Create an IoT hub

  5. Fill in the Basics tab: Basics tab of the IoT hub creation

FieldDescription
SubscriptionSubscription to use for your IoT hub.
Resource GroupNew resource group, or an existing one.
RegionRegion of your hub. Select the location closest to you.
IoT Hub NameName of your IoT hub. This name must be globally unique.
  1. Click Next: Networking. Select the connectivity method and click Next: Management. Networking tab of the IoT hub creation

  2. Fill in the Management tab depending on your needs, then click Next: Add-ons. Make sure that the shared access policies are enabled. Management tab of the IoT hub creation

FieldDescription
Pricing and scale tierTier of the hub, depending on the features you need and on the number of messages your solution sends per day.
IoT Hub unitsThe number of messages allowed per unit per day depends on the tier of your hub. For example, for an IoT hub that supports the ingress of 700,000 messages, choose two S1 units.
Advanced/Device-to-cloud partitionsNumber of partitions of the device-to-cloud messages, which relates to the number of simultaneous readers of the messages.

The number of units plays an important role in quotas and throttling.

Example​

ThrottleS1S2S3
Device-to-Cloud sends12 /sec/unit120 /sec/unit6,000 /sec/unit
Number of messages per day400,0006,000,000300,000,000

The number of devices depends on the subscriptions that you buy. For more information, see the pricing details.

This means that in order to reach a throughput of 300 uplinks/sec you need a minimum S1 subscription with 25 units (25 x 12 = 300).

The minimum D2C is 100 msg/sec, so even with S1 and 1 unit you can send 100 uplinks/sec. Starting with S1 and 9+ units, you can get above 100 msg/sec.

Another limitation is on the registry operations. Devices can be created dynamically, on the first uplink they send to the Azure connection. When there are many create operations at runtime, the registration of the devices can take time.

For example, registering 10,000 devices at the same time can take 100 min with an S1 subscription with one unit (10,000/100), and 4 min with an S1 subscription with 25 units (10,000/(25*100)).

The following table shows the enforced throttles. Values refer to an individual hub.

ThrottleS1S2S3
Identity registry operations (individual or bulk import/export operations)1.67/sec/unit (100/min/unit)1.67/sec/unit (100/min/unit)83.33/sec/unit (5,000/min/unit)
  1. In the Add-ons tab, you can add other Microsoft services if needed. They are not required by ThingPark. Click Next: Tags. Add-ons tab of the IoT hub creation

  2. You can add one or several tags. Then, click Next: Review + create. Tags tab of the IoT hub creation

  3. After reviewing the details, click Create. Review and create the IoT hub

  4. Wait until the deployment of the hub is complete.

  5. Click Go to resource. The details of your IoT hub are displayed. IoT hub created

Collecting Expected Information​

Parameters required​

UI FieldDescription
NameName of the connection.
HostnameHost name of your Azure IoT hub, for example myaccountname.azure-devices.net.
Access Policy NameName of a shared access policy of the IoT hub, for example iothubowner.
Shared Access KeyPrimary or secondary key of this shared access policy.
IoT Hub TierPricing and scale tier of your IoT hub: Free (F1), Basic level 1 (B1), Basic level 2 (B2), Basic level 3 (B3), Standard level 1 (S1), Standard level 2 (S2) or Standard level 3 (S3). Default Free (F1).
IoT Hub UnitsNumber of units of your IoT hub. Default 1. The Free tier has only 1 unit. A level 1 or 2 tier can have up to 200 units. A level 3 tier can have up to 10 units.
DescriptionOptional description of the connection.

The following settings are in the connection details, once the connection is created:

UI FieldDescription
Exclusive IoT-HubOn by default. See Exclusive IoT-Hub mode.
Downlink portIn the Advanced Settings section. When downlinks are enabled, LoRaWAN® port used to send the downlinks to the device.

For detailed information on Microsoft Azure IoT configuration and parameters, see the Azure IoT Hub documentation.

Getting the Information From the Azure Portal​

  1. Log in to the Azure Portal.

  2. The main page shows the resources that you have created. Resources in the Azure portal

  3. Select your IoT hub, TPX-Connector in this example.

  4. The Overview page gives the Hostname, the Pricing and scale tier and the Number of IoT Hub units. Overview of the IoT hub

  5. Open Shared access policies, under Security settings in the left panel. The page lists the policies that exist by default. Make sure that the Connect using shared access policies option is set to Allow. Shared access policies of the IoT hub

    • To use an existing shared access policy, select iothubowner: this is the Access Policy Name. The panel that opens on the right gives its Primary key and Secondary key. The iothubowner shared access policy

    • Or create a new shared access policy:

      • Click Add shared access policy.
      • Enter a name for the policy, for example actility-policy.
      • Allow the Registry read, Registry write and Device connect permissions.
      • The new policy appears in the list. Select it: the panel on the right gives its name and its primary and secondary keys.

Creating a Connection With UI​

  1. In ThingPark Enterprise, click Connections -> + Add Connection -> ThingPark X IoT Flow. Add a ThingPark X IoT Flow connection in ThingPark Enterprise

  2. In ThingPark X IoT Flow, click Azure IoT Hub in the list of connectors. Select the Azure IoT Hub connector

  3. Fill in the form:

    • Name: a clear name for the connection, for example My Azure IoT Hub Connection.
    • Hostname: the host name of your IoT hub, given on its Overview page.
    • Access Policy Name: the name of the shared access policy, for example iothubowner.
    • Shared Access Key: the primary or secondary key of this policy.
    • IoT Hub Tier: the pricing and scale tier given on the Overview page of your IoT hub.
    • IoT Hub Units: the number of IoT hub units given on the same page.
    • Description: optional. Set your Azure IoT Hub connection
  4. Click Create. A notification confirms that the connection has been created, and the connection details open.

  5. In the connection details, check that the connection is OPENED (see Connection States).

Note

Parameters marked with * are mandatory.

Creating a Connection With API​

The Actility Azure connection uses AMQPS protocol.

You need to create the connection prior to creating the flow.

The creation of a connection establishes a link from ThingPark Wireless to the cloud provider that you want to associate a Device with. The link can be used to transport any Uplink regardless the DevEUI parameter.

Note

The DevEUI must be always in upper case.

Azure IoT Hub allows only one active connection per device.

To do this, you need to use the following endpoints.

  • POST/connections for creation
  • PUT/connections for modification
  • DELETE/connections for deletion
Note

When you update a configuration property on a connection, you must provide the whole configuration properties again.

Example of the creation of a connection:

POST /connections

{
"connectorId": "actility-azure-iot",
"name": "Azure Connection",
"configuration": {
"description": "Azure Datacenter",
"hostName": "demo.azure-devices.net",
"sharedAccessKeyName": "iothubowner",
"sharedAccessKey": "{YOUR-SHARED-ACCESS-KEY}",
"iotHubTier": "S1",
"iotHubUnits": 25
}
}

The following table lists the expected results of the properties when applied:

PropertyExpected results
connectorIdSet to actility-azure-iot.
configuration/hostNameDefines the host of the Azure IoT Hub to use.
configuration/sharedAccessKeyNameShared Access Policy name for accessing the Azure IoT Hub.
configuration/sharedAccessKeyPrimary or Secondary key for accessing the Azure IoT Hub.
configuration/iotHubTierPricing and scale tier of the Azure IoT Hub.
configuration/iotHubUnitsNumber of IoT Hub units of the Azure IoT Hub.
configuration/downlinkEnabledtrue (default) for the Exclusive IoT-Hub mode, false for a shared, uplink-only access. See Exclusive IoT-Hub mode.
Important note

All properties are not present in this example. You can check the rest of these properties in the common parameters section.

Azure IoT Hub Certificate Migration​

Migration to DigiCert Global Root G2

Azure IoT Hub used TLS certificates issued by the Baltimore CyberTrust Root, which expires in 2025. Starting in February 2023, all IoT hubs in the global Azure cloud migrate to a new TLS certificate issued by the DigiCert Global Root G2.

Actility has tested this certificate migration according to the Azure recommendations: the connector is compatible with the new certificate.

Displaying Information to Know if It Worked​

First, collect the connection string of your Azure IoT hub:

  1. In the Azure portal, select your IoT hub.

  2. In the Shared access policies page, select the policy used by the connection.

  3. Copy the Primary connection string.

Example of connection string: HostName=<IoT Hub name>.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=<primary key>

Using Azure IoT Explorer​

  1. Install the latest Azure IoT Explorer for your operating system: the file with the .msi extension for Windows, .deb for Linux.

  2. Open the application and click Add connection. Add a connection in Azure IoT Explorer

  3. Enter the Connection string of your IoT hub, and click Save. Connection string in Azure IoT Explorer

  4. Azure IoT Explorer lists the devices of the IoT hub. Click a device ID to inspect the device and monitor its telemetry. Telemetry in Azure IoT Explorer

Using Azure CLI​

  1. Install the latest Azure CLI.

  2. Install the Azure IoT Extension for Azure CLI:

az extension add --name azure-iot
  1. Run the following command to monitor the events of a device:
az iot hub monitor-events -n {iothub_name} --login {iothub_connection_string} -d {device_id}

Example:

az iot hub monitor-events -n iot-hub-tests --login "HostName=iot-hub-tests.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey={YOUR-SHARED-ACCESS-KEY}" -d 17zp509311000493

The uplinks of the device are displayed:

Device events in Azure CLI

Limitations​

Currently, the Actility Azure connection supports up to 32,750 devices when Exclusive IoT-Hub mode is enabled and 65,500 devices when it is disabled, in the same IoT Hub. This limitation is due to the maximum number of Device-to-cloud telemetry and Cloud-to-device links that the Azure SDK can open concurrently. If you reach this limit, new devices are not taken into account, and restarting the connection does not guarantee that the same devices will be established. Azure Event Hubs is a more stable solution for larger deployments.

The connector supports only device-to-cloud telemetry sends (D2C) for uplinks and cloud-to-device sends (C2D) for downlinks. Other Azure operations like File upload, Direct methods or Device Twin are not supported.

All other limits are imposed by Azure based on the subscription and the number of units.

To select the subscription that fits your case check the IoT Hub limits documentation.

The Device Identifier (DevEUI) must be in uppercase on the Azure IoT Hub side.

Exclusive IoT-Hub mode​

The Exclusive IoT-Hub option controls how ThingPark X IoT Flow creates Azure device links. It is enabled by default in the UI and in the API configuration.

  • Enabled: ThingPark X IoT Flow establishes bidirectional links for the devices in the IoT Hub. It lists the existing devices when the connection starts, opens both uplink and downlink links, and supports downlinks. Only one active connection can own the downstream link for a device. Do not enable this mode on multiple connections that use the same IoT Hub.
  • Disabled: ThingPark X IoT Flow does not open downlink links and does not list all existing devices at startup. It creates an uplink link on demand when a device sends an uplink. This mode supports multiple connections sharing one IoT Hub for uplinks, but those connections cannot receive downlinks.

In the API, this UI option is represented by configuration.downlinkEnabled for backward compatibility. Set it to true for Exclusive IoT-Hub mode or false for shared uplink-only access. The API does not use an exclusiveIoTHub property.

If multiple connections use the same IoT Hub with Exclusive IoT-Hub mode enabled, they collide on downstream links because Azure allows only one active downstream link per device.

A Link errors event is stored in the Event table. Each connection retries to acquire downstream links every minute, but the collision continues until only one exclusive connection per IoT Hub remains. Disable Exclusive IoT-Hub mode on the other connections by setting downlinkEnabled=false.

Another downside of this collision is that upstream links will not be able to enforce proper rate limiter when sending uplinks.

The reason is that the rate limiter is not shared between connections and each connection will push uplinks at a maximum possible rate according to the IoT Hub subscription.

However, at some point it may exceed the global IoT Hub rate per minute and uplinks may start to be Rejected by Azure.

A way to avoid downstream-link collisions is to set downlinkEnabled=false on most concurrent connections and leave it set to true (the default) on only one connection. Uplinks can then be sent through multiple connections, while downlinks are received through one exclusive connection.

When downlinkEnabled=false, the Azure connection does not list existing devices in the IoT Hub and creates uplink links lazily when devices send their first uplink.

Troubleshooting​

The following table lists the common error codes returned by Azure IoT Hub AMQP Broker:

Error codeError descriptionComments
amqp:internal-errorAnother AMQP Client has opened a Receive LinkThe device is already used by another AMQP client. Setting downlinkEnabled=false on the other connections to the same IoT Hub prevents downstream-link collisions. Check the Link errors events in the event log.
amqp:not-allowedDevice used by another AMQP client, like the above error code
amqp:not-foundDevice not found due to case sensitive device id or because it is not anymore on the IoT Hub.

There is no action to perform. The device links will be closed and removed from the Azure Connection.

IoT-Flow uses uppercase deviceEUI / device id.
amqp:internal-errorDevice Not Found ErrorCode:DeviceNotFound ...Device deleted manually from the Cloud side. Azure will close the device links after 1-2 minutes.

There is no action to perform. The device links will be closed and removed from the Azure Connection.
amqp:link:detach-forcedServer Busy. Please retry operationWhen Azure is overloaded, it will detach the device links. The device links will be retried automatically every 1 min.
amqp:resource-limit-exceededTotal number of messages on IotHub '...' exceeded the allocated quota. Max allowed message count : '...', current message count : '...'. Send and Receive operations are blocked for this hub until the next UTC day. Consider increasing the units for this hub to increase the quota ...When the daily quota of messages is reached, the Azure IoT Hub rejects new message exchange. The Azure connection will close. The supervisor will retry the connection based on reconnectStrategy.
However, until the next day this connection will not be able to re-open it successfully. If you need to send more messages until the next day, you need to manually increase the hub units from your IoT Hub Dashboard. Update the connection configuration with the new iotHubUnits number.
Device number limit exceededTotal number of devices IotHub '...' exceeded the maximum that can be allocated.The maximum is 32,750 devices in Exclusive IoT-Hub mode and 65,500 devices when it is disabled.
IotHubQuotaExceededTotal number of messages on the IoT Hub exceeded the allocated quota. Increase units for this hub to increase the quota.