如何解决物联网中心自定义规则
目前正在寻求有关此网站 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 的电子邮件?为了进一步分析,您能否还确认您的流分析作业正在接收来自事件中心的输入?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。