azure - IoT Central 到 Blob 存储数据加密遥测数据主体

标签 azure azure-blob-storage azure-iot-hub azure-iot-central

我在将遥测数据/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. 使用分配给设备1的 PnP 设备模板 (environmentalSensor) 并将数据导出到 Blob 存储来创建 IOT Central 应用程序:

enter image description here

  • 使用 Azure IoT 中心测试器模拟通过 MQTT 协议(protocol)直接连接到 IoT Central 的 PnP 设备1:
  • enter image description here

    如您所见,发布的主题是

    devices/device1/messages/events/$.ct=application%2Fjson&$.ce=utf-8
    

    并且 6 条消息已发送到 IoT Central。

  • 在 IoT Central 仪表板上显示遥测数据。
  • enter image description here

  • 使用 Azure 存储资源管理器探索 Blob 内容:
  • enter image description here

    如您所见,每个设备消息的正文不是 Base64 编码的 json 文本。

    请注意,只有设备消息的 contentTypecontentEncoding 才能决定正文是否采用 Base64 编码。

    关于azure - IoT Central 到 Blob 存储数据加密遥测数据主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59065806/

    相关文章:

    Python 记录器异常在 Azure Application Insights(Azure Function)中记录为跟踪

    node.js - Azure移动服务错误找不到模块 'azure-storage'

    c# - 将 Azure.AsyncPageable<BlobItem> 转换为 List<BlobItem>

    azure - 使用 JavaScript 将文件放入 Blob 存储会导致 403(服务器无法验证请求)

    azure - 将设备到云消息发送到 IoTHub 时,是否可以重用 Azure Functions 上的连接?

    javascript - 如何获取token并保存以供以后使用而不需要每次登录?

    sql - 无法从 SSMS 2012 远程连接到 SQL Azure

    Azure 存储 : For business purposes, 是拥有较多文件夹且较少的容器更好,还是拥有较多文件夹的较少容器更好?

    c# - Azure SDK UnauthorizedException : Put token failed. 状态代码 : 401, 状态描述:未经授权:当 KeyName 为空时,资源 URI 必须

    asp.net - Azure - 将数据从 IoT 中心发送到 Web 应用程序后端