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

查看:83
本文介绍了如何在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天全站免登陆