Azure IoT hub routing to storage account Add Device ID to file path

Saltzmann, Eric 1 Reputation point
2022-12-22T14:46:07.79+00:00

Is it possible to add the device id as part of the file path for a storage account endpoint? I didn't find any additional parameters that are available to use with the file path format.

{iothub}/{connectionDeviceId}/{partition}/{YYYY}/{MM}/{DD}/{HH}/{mm}

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,130 questions
{count} votes

2 answers

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 13,621 Reputation points
    2022-12-22T21:34:17.137+00:00

    Hi @Saltzmann, Eric , Welcome to Micrsoft Q&A forum! Thank you for posting this question.

    Azure IoT Hub routing for storage accounts currently does support passing in Device ID parameter dynamically. There is a product request created for this feature in the past. You can view the request using the following URL -- Include device id in file name format as parameter. Please upvote the feature request.

    Even though we cannot add the Device ID dynamically, we can add device names as statics strings in the file name format and can bind this custom end point to a route. Please refer the below image

    273385-image.png

    If you are okay with choosing a different end point, Azure Cosmos DB routing end point (currently offered as preview) supports creation of partition key items based on device ID. Please refer the below image for details

    273447-image.png

    Please let me know if the above shared information is useful.

    ----------

    • Kindly accept answer or upvote if the response is helpful so that it would benefit other community members facing the same issue.
    • Original posters help the community find answers faster by identifying the correct answer. Here is how
    • I highly appreciate your contribution to the community.
    0 comments No comments

  2. QuantumCache 20,031 Reputation points
    2023-03-10T00:02:05.8266667+00:00

    Hello @Saltzmann, Eric,

    That's correct. The Azure IoT Hub routing for storage accounts doesn't currently support dynamically passing in the Device ID parameter as part of the file path. However, you can achieve this by using Azure Functions and Event Grid.

    You can create an Azure Function that listens to the Event Grid events generated by the IoT Hub for device telemetry, and then process those events to extract the device ID and the telemetry data. You can then use the device ID to create the file path dynamically and write the telemetry data to the appropriate file.

    Here's a high-level overview of the steps involved:

    1. Create an Azure Function that listens to the Event Grid events generated by the IoT Hub for device telemetry.
    2. In the Function code, extract the device ID and the telemetry data from the event.
    3. Use the device ID to create the file path dynamically, and write the telemetry data to the appropriate file.
    4. Configure the IoT Hub to route device telemetry to the Event Grid.
    5. Configure the Event Grid subscription to send device telemetry events to the Azure Function.

    This approach provides more flexibility in terms of the file path format and enables you to process the telemetry data before writing it to the storage account.

    0 comments No comments