azure - 获取流分析中的消息对象属性

标签 azure azure-functions azure-stream-analytics

这是一个示例 JSON 输入数据包。我正在编写转换查询来获取数据,它工作正常。

[{
      "source": "xda",
      "data": 
        [{
            "masterTag": "UNIFY",
            "speed": 180
        }],
      "EventEnqueuedUtcTime": "2018-07-20T19:28:18.5230000Z",
  },
  {
      "source": "xda",
      "data": [{
            "masterTag": "UNIFY",
            "speed": 214
        }],
      "EventEnqueuedUtcTime": "2018-07-20T19:28:20.5550000Z",
  }
]

但是,当消息对象通过名称“proFilter”发送到 IoT 中心时,已将自定义属性添加到消息对象中。它不在有效负载内,但存在于消息对象中。我可以使用 Azure 函数获取此属性,但我不确定如何在流分析转换查询中获取它。有什么办法可以得到它吗?

基本转换查询:

WITH data AS
(
    SELECT
        source,
        GetArrayElement(data,0) as data_packet 
    FROM input 
)

SELECT 
    source, 
    data_packet.masterTag 
INTO 
    output
FROM data

最佳答案

SELECT 语句中包含以下函数:

GetMetadataPropertyValue(input, '[User].[proFilter]') AS proFilter

如果您有兴趣将所有自定义属性作为记录检索,您可以使用

GetMetadataPropertyValue(input, '[User]') AS userprops

参见this doc for further reference

关于azure - 获取流分析中的消息对象属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51539417/

相关文章:

json - 将 JSON 事件聚合到 Azure 流分析中的数组中

azure - 如何在Azure上进行负载平衡/端口转发?

azure - 从 Azure 下载 blob 时未找到远程服务器错误

azure - 如何检查我的 ASP.NET Core 是否在 Azure 上运行?

c# - 为什么部分封闭的泛型在函数中运行时有效,但在直接调用 ServiceCollection 时却无效?

azure - 为 VueJs 前端和 Azure 函数应用程序后端实现身份验证/授权的最佳方法是什么

azure - 流分析: How can I start and stop a TUMBLINGWINDOW aggregation job inorder to reduce costs while still getting the same aggregation results?

azure - 来自远程 terraform 模块的输出变量

azure - Microsoft.Azure.WebJobs.Extensions.EventGrid : Object reference not set to an instance of an object

azure - 是否可以在ARM模板中创建documentDB数据库和帐户