问题描述
目前正在寻求有关此网站 https://docs.microsoft.com/en-us/azure/iot-central/core/howto-create-custom-rules 代码的帮助。在使用使用查询来检测断开连接的 deviceid 的流分析作业时,它返回 null。请参阅如下:[断开连接的设备的所有 deviceid 返回空值,但时间戳在那里。][1]
这是我使用的查询。
with
LeftSide as
(
SELECT
-- Get the device ID from the message Metadata and create a column
GetMetadataPropertyValue([centraltelemetry],'[EventHub].[IoTConnectiondeviceid]') as deviceid1,EventEnqueuedUtcTime AS time1
FROM
-- Use the event enqueued time for time-based operations
[centraltelemetry] TIMESTAMP BY EventEnqueuedUtcTime
),RightSide as
(
SELECT
-- Get the device ID from the message Metadata and create a column
GetMetadataPropertyValue([centraltelemetry],'[EventHub].[IoTConnectiondeviceid]') as deviceid2,EventEnqueuedUtcTime AS time2
FROM
-- Use the event enqueued time for time-based operations
[centraltelemetry] TIMESTAMP BY EventEnqueuedUtcTime
)
SELECT
LeftSide.deviceid1 as deviceid,LeftSide.time1 as time
INTO
[emailnotification]
FROM
LeftSide
LEFT OUTER JOIN
RightSide
ON
LeftSide.deviceid1=RightSide.deviceid2 AND DATEDIFF(second,LeftSide,RightSide) BETWEEN 1 AND 120
where
-- Find records where a device didn't send a message 120 seconds
RightSide.deviceid2 is NULL
```[enter image description here][2]
[1]: https://i.stack.imgur.com/CLOQv.png
[2]: https://i.stack.imgur.com/IU3SX.png
解决方法
由于流分析查询使用来自事件中心的遥测作为其输入,如果您遵循了完整的设置教程,请告诉我吗?如果是,您是否看到带有设备 ID 的功能日志消息?
另外,您是否收到 SendGrid 发送的带有设备 ID 的电子邮件?为了进一步分析,您能否还确认您的流分析作业正在接收来自事件中心的输入?