Parse json events from azure time series insights with C#

554 views Asked by At

Are there any standards for how to parse the json response from Azure Time Series API? It looks a lot like JSON schemas, but not quite.

It's hard to find any guidelines from Microsoft on how to handle the parsing. Deserializing with JSON.NET is also tricky because property names can consist of dots when a nested data object has been sent.

Sample json:

{
    {
        "warnings": [],
        "events": [
            {
                "schema": {
                    "rid": 0,
                    "$esn": "Test",
                    "properties": [
                        {
                            "name": "a.identifier",
                            "type": "String"
                        },
                        {
                            "name": "a.number",
                            "type": "Double"
                        },
                        {
                            "name": "descr",
                            "type": "String"
                        }
                    ]
                },
                "$ts": "2018-01-21T22:57:00.095Z",
                "values": [
                    "test",
                    2.1,
                    "fdsasf"
                ]
            },
            {
                "schemaRid": 0,
                "$ts": "2018-01-21T22:57:00.095Z",
                "values": [
                    "test2",
                    223,
                    "gjmnsfg"
                ]
            },
            {
                "schemaRid": 0,
                "$ts": "2018-01-21T22:57:00.095Z",
                "values": [
                    "test3",
                    43.5,
                    "sasd"
                ]
            }
        ]
    }
}
2

There are 2 answers

0
Vladislav On

I have to disappoint you, that I was also looking for this info, but until now didn't find anything. Indeed, the only on-topic info provided by MSFT that I can see, is the link provided by Rui Jarimba, Azure Time Series Insights Query API. But that is just nothing.

The best you can do is just explore it yourself.

Nevertheless, I have few useful things to mention here:

  • the generated "schema" object is case-sensitive on the properties' names returned in each event. So if you have "timestamp" and "Timestamp", you will end-up with separate schemas for these events (the schemaRid will be different)
  • there is a GitHub sample "Hello, World" project that provides some query examples along with result parsing which could be useful for some basic references

Hope this helps.

1
ashannon7 On

I'm Andrew, a PM on the Time Series Insights team. I think what you're looking for is here. We flatten JSON, and dimension properties are stored alongside telemetry data.