azure - 如何在 Microsoft Azure 流分析上从多个设备中分离数据
问题描述
我目前正在尝试将 2 个不同的设备连接到 IoT 中心,我需要将数据与每个设备分开。为此,我尝试像这样配置我的流分析查询:
SELECT
deviceId, temperature, humidity, CAST(iothub.EnqueuedTime AS datetime) AS event_date
INTO
NodeMCUOutput
FROM
iothubevents
WHERE
deviceId = "NodeMCU1"
但是,由于某种原因,如果 WHERE 语句在代码中,则不会显示输出(没有显示输出,但未过滤数据)。我需要 WHERE 语句才能按照我想要的方式对数据进行排序。我错过了什么吗?有什么解决办法吗?非常感谢。干杯!
解决方案
消息本身中不包含的设备 ID 和其他属性作为元数据包含在消息中。GetMetadataPropertyValue()
您可以使用该函数读取该元数据。这应该适合你:
SELECT
GetMetadataPropertyValue(iothubevents, 'IoTHub.ConnectionDeviceId') as deviceId,
temperature,
humidity,
CAST(GetMetadataPropertyValue(iothubevents, 'IoTHub.EnqueuedTime') AS datetime) AS event_date
INTO
NodeMCUOutput
FROM
iothubevents
WHERE
GetMetadataPropertyValue(iothubevents, 'IoTHub.ConnectionDeviceId') = 'NodeMCU1'
推荐阅读
- colors - a-frame 使我的模型纹理的颜色饱和
- php - if 语句为真但未执行
- amazon-web-services - 如何在 AWS DocumentDB 中设置不区分大小写的唯一索引?
- c++ - 使用 make 命令时编译错误
- php - Laravel 使用 Auth::user() 从另一个表中获取数据
- android - Kotlin - Retrofit2 onResponse null Openweather
- flutter - 列小部件没有收缩
- javascript - 数据表行重新排序停止使用列排序
- javascript - 在我的传单扩展中访问 VueJS “this”
- r - 在R中,将多列的行总和分配给其他列