Azure 流分析查询 JSON

Azure Stream Analytics Querying JSON

我在编写查询以从 json 文件的数组中提取 table 时遇到问题:问题是如何获取数组“clientPerformance”的信息,然后使他们都是正常的 sql table.

文件如下所示:

"clientPerformance":[  
        {  
         "name":"opportunity",
         "clientProcess":{  
            "value":3620000.0,
            "count":1.0,
            "min":3620000.0,
            "max":3620000.0,
            "stdDev":0.0,
            "sampledValue":3620000.0
         },
         "networkConnection":{  
            "value":10000.0,
            "count":1.0,
            "min":10000.0,
            "max":10000.0,
            "stdDev":0.0,
            "sampledValue":10000.0
         },
         "receiveRequest":{  
            "value":9470000.0,
            "count":1.0,
            "min":9470000.0,
            "max":9470000.0,
            "stdDev":0.0,
            "sampledValue":9470000.0
         },
         "sendRequest":{  
            "value":1400000.0,
            "count":1.0,
            "min":1400000.0,
            "max":1400000.0,
            "stdDev":0.0,
            "sampledValue":1400000.0
         },
         "total":{  
            "value":14500000.0,
            "count":1.0,
            "min":14500000.0,
            "max":14500000.0,
            "stdDev":0.0,
            "sampledValue":14500000.0
         },
         "url":"https://xxxx",
         "urlData":{  
            "base":"/main.aspx",
            "host":"xxxx",
            "hashTag":"",
            "protocol":"https"
         }
      }
   ]

我尝试使用获取数组元素方法和其他方法,但我始终无法访问 clientProcess、networkConnection.. elements

我试着用这个作为例子:

Select 
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'name') AS Name,
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 1), 'clientProcess.count') AS clientProcessCount,
FROM [app-insights-blob-dev] Input 

如有任何帮助,我将不胜感激:)

我将您的查询略微编辑为 return clientProcessCount。 (我将数组索引从 1 更改为 0)。还要确保您的 JSON 对象以 { 开头并以 } 结尾。

Select
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'name') AS Name,
GetRecordPropertyValue(GetArrayElement(Input.clientPerformance, 0), 'clientProcess.count') AS clientProcessCount
FROM [app-insights-blob-dev] Input

有关使用 ASA 查询复杂对象的其他示例,请随时查看此 blog post