我在将遥测数据/json 保存到 blob 存储中时遇到问题。 问题是保存的数据已经对我有值(value)的遥测数据进行了加密。
{"EnqueuedTimeUtc":"2019-11-25T15:42:51.5340000Z","Properties":{},"SystemProperties":{"to":"/devices/device-08/messages/events","connectionDeviceId":"device-08","connectionAuthMethod":"{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}","connectionDeviceGenerationId":"xxxxxxxxxxxxx","contentEncoding":"","enqueuedTime":"2019-11-25T15:42:51.5340000Z"},"Body":"eyJ0ZW1wIjo3LjM5LCJodW0iOjczLjUsInJzc2kiOi04OSwic25yIjo4Ljh9"}
我认为问题也出在“contentEncoding”:“”,因为它应该是“contentEncoding”:“utf-8”。
有谁知道如何解决这个问题:)非常感谢您的努力!
最佳答案
看看this文档。
设置设备消息系统属性,例如将 contentType 设置为 application/json,将 contentEncoding 设置为 UTF-8>.
如果您的设备直接使用MQTT协议(protocol),则使用Topic来传递系统属性,例如:
devices/mydeviceId/messages/events/$.ct=application%2Fjson&$.ce=utf-8
更新:
以下屏幕片段显示了将数据导出到 Blob 存储的快速测试示例。
- 使用分配给设备1的 PnP 设备模板 (environmentalSensor) 并将数据导出到 Blob 存储来创建 IOT Central 应用程序:
- 使用 Azure IoT 中心测试器模拟通过 MQTT 协议(protocol)直接连接到 IoT Central 的 PnP 设备1:
如您所见,发布的主题是
devices/device1/messages/events/$.ct=application%2Fjson&$.ce=utf-8
并且 6 条消息已发送到 IoT Central。
- 在 IoT Central 仪表板上显示遥测数据。
- 使用 Azure 存储资源管理器探索 Blob 内容:
如您所见,每个设备消息的正文不是 Base64 编码的 json 文本。
请注意,只有设备消息的 contentType 和 contentEncoding 才能决定正文是否采用 Base64 编码。
关于azure - IoT Central 到 Blob 存储数据加密遥测数据主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59065806/