Send Data to Azure IoT Hub with an SAS Key
Review the following guide for setting up an outbound data integration between Litmus Edge and Azure IoT Hub using an SAS Key.
You must first Set up an Azure IoT Hub.
Follow the steps to Add a Connector and select the MQTT - Azure IoT Hub using SAS Key provider.
Configure the following parameters.
- Name: Enter a name for the connector.
- Hostname: Enter the IP address or server FQDN of the MQTT broker (must be reachable from your edge device).
- Port: The MQTT broker's port number. The default value is 8883.
- Client ID: Copy the Device ID of your edge device from the IoT Devices page in the Azure portal and paste it here.
- SAS Key: Copy the primary or secondary shared access key from the IoT Devices page in the Azure portal and paste it here.
- Parallel Publish Count: The maximum number of concurrently published messages. The default value is 16.
- Integration Topic: The default topic to publish or subscribe to: devices/[deviceId]/messages/events/. Replace [deviceId] with the Device ID copied from Azure.
- Token TTL: The token expiry time in minutes. The default value is 1440.
- LWT Topic: The topic for MQTT's Last Will and Testament feature.
- LWT payload: The payload for MQTT's Last Will and Testament feature.
- LWT payload type: The payload type for MQTT's Last Will and Testament feature. The options are string and base64.
- LWT QoS: The Quality of Service value for MQTT's Last Will and Testament feature.
- LWT retained: Select this check box to retain the value for MQTT's Last Will and Testament feature.
- Throttling Limit: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.
- Persistent storage: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Litmus Edge when cloud providers are online.
- Queue Mode: Select the queue mode as lifo (last in first out) or fifo (first in first out). Selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first.
After adding the connector, click the toggle in the connector tile to enable it.
If you see a Failed status, you can review the Connector Logs and relevant error messages.
You will now need to create topics from the tags you added in Step 2.
Before creating the topics copy the Raw Topic parameter for all tags you want to use for topics. See Manage Tags for more information.
To create topics:
- Click the connector tile. The connector Dashboard appears.
- Click the Topics tab.
- Add topics to the connector with the details below. See Add Topics to Connectors for more information.
- Data Direction: Select Local to Remote - Outbound.
- Local Data Topic: Paste the Raw Topic for the tag created in Step 2.
- Remote Data Topic: Verify the format of the remote data topic is devices/[DeviceID]/messages/events/. Replace [DeviceID] with the Device ID parameter configured for the connector. devices/MyDevice/messages/devicebound/%24.to=%2Fdevices%2Fmessages%2Fdevicebound.
- Enable: Click the toggle to enable the topic.
- Click Yes to add the topic.
- After adding all required topics, navigate to the Integration pane.
- From the connector tile, ensure the connector is not disabled and still shows a CONNECTED status.
Once data is sent to the Azure IoT Hub, you can manage it as needed. Refer to the Azure IoT Hub Documentation to learn more.