如何在 Microsoft Azure 流分析上从多个设备中分离数据 [英] How to Separate Data from Multiple Devices on Microsoft Azure Stream Analytics

查看:13
本文介绍了如何在 Microsoft Azure 流分析上从多个设备中分离数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试将 2 个不同的设备连接到 IoT 中心,我需要将数据与每个设备分开.为此,我尝试像这样配置我的流分析查询:

I am currently trying to connect 2 different devices to the IoT Hub, and I need to separate the data from each device. In order to do so, I tried configuring my stream analytics query like this:

SELECT
    deviceId, temperature, humidity, CAST(iothub.EnqueuedTime AS datetime) AS event_date
INTO
    NodeMCUOutput
FROM
    iothubevents
WHERE
    deviceId = "NodeMCU1"

但是,由于某种原因,如果 WHERE 语句在代码中,则不会显示输出(在没有它的情况下显示输出,但未过滤数据).我需要 WHERE 语句才能按照我想要的方式对数据进行排序.我错过了什么吗?有什么解决办法吗?非常感谢.干杯!

However, for some reason, the output is not shown if the WHERE statement is in the code (the outputs are shown without it, but the data is not filtered). I need the WHERE statement in order to sort the data the way I want it. Am I missing something? Are there any solutions to this? Thanks a lot. Cheers!

推荐答案

消息本身不包含的设备 ID 和其他属性作为元数据包含在消息中.您可以使用 GetMetadataPropertyValue() 函数读取该元数据.这应该适合你:

The device ID and other properties that are not in the message itself are included as metadata on the message. You can read that metadata using the GetMetadataPropertyValue() function. This should work for you:

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'

这篇关于如何在 Microsoft Azure 流分析上从多个设备中分离数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆