This section explains how to provision a gateway and how to connect to the Azure IoT Services using a Connection String. This connection method is used directly with the IoT Hub.
ESF Cloud Connector for Azure IoT, Version 2.0.0 and Above Only
These instructions apply to the ESF Cloud Connector for Azure IoT, Version 2.0.0 and above. See Legacy v2 Azure IoT Connection if you are using any version under 2.0.0.
Go to your IoT Hub in the Azure Portal.
Note: This is in your IoT Hub, not your IoT Hub DPS. Ensure the Azure resource type is IoT Hub when you are selecting the resource.
Go to the IoT devices page and click + New.
On the Create a eevice page, enter the following information:
- Device ID: This can be any unique designator. A good method to ensure this is unique is to use the gateway's MAC address and serial number (in the format [MACAddress]-[SerialNumber])
- Authentication Type: Symmetric Key
- Primary key: Leave blank (will be auto-generated)
- Secondary key: Leave blank (will be auto-generated)
- Auto-generate keys: Ensure this box is checked
- All other fields: Leave at the default values
In the ESF Web interface, go to the Cloud Connection section and click New Connection.
On the New Cloud Connection dialog, enter the following information:
- Cloud Connection Factory PID: AzureConnectionString
- Cloud Connection Service PID: AzureConnectionString or other valid Cloud Connection Service PID
Select the new connection and go to the ConnectionStringDataTransport tab.
Set the Device Model ID to "dtmi:Eurotech:RG_10_12_6x;3" (without the quote marks).
Go to the IoT devices page in your IoT Hub. The Azure Portal should have already directed you here after creating the new device. Locate your device on the list of devices and click its Device ID to go to the device details page.
Copy the Primary Connection String and paste it into the Connection String in ESF.
Copying the Connection String
Copying the connection string in the Azure Portal can be accomplished by clicking the "copy" icon to the right of the Primary Connection String field, or by making the connection string visible by clicking the eyeball icon and manually selecting and copying the connection string.
Click Apply in ESF.
Click the Connect/Disconnect button. The Status should change to Connected. The connection process may take up to 30 seconds.
The device is now connected.
Updated about 2 months ago