How to ingest dynamic data to ADX?

jane 60 Reputation points
2023-11-17T07:47:58.6866667+00:00

I am connecting to Azure IoT Hub through Azure Data Explorer (ADX) to get JSON-formatted streaming data. However, this JSON is in a nested format, and the fields of the nested objects are not fixed. How can I flatten and store it in ADX?

The JSON data like follows:

{

"type":"fruit",

"recordTime":"2023-11-09 11:09:21",

"apple":{

"weight":200,

"price":3.15

}

And the apple may have more property.I want store it in a table on ADX like follows: apple: type,recordTime,weight,price,...

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,149 questions
Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
502 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 30,786 Reputation points MVP
    2023-11-17T08:22:15.16+00:00

    Hello @jane,

    welcome to this moderated Azure community forum.

    When ingesting data from an IoT Hub, you need to create a mapping for the data connection. Check out this blog post for an example.

    Is this message mapped to a dynamic column names like 'data'?

    In that case, you can access the weight:

    tableName
    | project weight = data.apple.weight
    

    If you want to map it directly to a typed column, you need to check the mapping like:

    '{"Column": "weight", "Properties": {"Path": "$.apple. Weight"}},'
    

    Please check out that article for a full story.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


0 additional answers

Sort by: Most helpful