azure-iot-hub - IoT 中心设备孪生中的 etag 有什么用?

标签 azure-iot-hub

我正在 .NET Core 3 中开发 Web 应用程序,我正在使用 Microsoft.Azure.Devices.RegistryManager 访问 Azure Iot 中心。

当我调用 registryManager.UpdateTwinAsync() 时,我必须发送“etag”。有时 etag 会发生变化,我会收到错误消息,指出存在 etag 不匹配。

我基本上不明白 etag 的用途是什么以及如何以安全的方式更新设备孪生。有人吗?

我 try catch 这些异常并从设备孪生中获取 etag 并连续重试多达 15 次,中间等待 2 秒,这很有帮助,但此错误时不时会弹出。我认为应用设备 ID 足以更新设备孪生但显然不是

请帮忙!

最佳答案

因此,简单来说,我们可以说,只要我们看到设备状态发生变化或任何其他更新,ETag - 实体标签就会不断变化。

A string representing a weak ETag for the device identity, as per RFC7232 Section 2.3 Etag.

An entity-tag is an opaque validator for differentiating between multiple representations of the same resource, regardless of whether those multiple representations are due to resource state changes over time

例如:启用和禁用 IoT 设备并检查 Visual Studio Code 中的“获取设备信息”(Azure IoT Hub Extension)

第 1 步) 我有一个状态为已启用的初始物联网设备,我可以看到一个 Etag 值。

步骤 2) 当我在 IoT 中心门户上禁用设备,然后进行第二次查询“获取设备信息”调用时,我在 ETag 上看到了不同的值。

enter image description here

第 3 步) 现在,当我第二次查询时(例如间隔 5 分钟后),我看到对于相同的设备禁用状态,Etag 值保持不变 .

enter image description here

**更多信息请访问Device identity properties , Module identity properties

**如果您需要更多帮助,请告诉我们!

关于azure-iot-hub - IoT 中心设备孪生中的 etag 有什么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62389880/

相关文章:

node.js - 在 Javascript 中使用 MQTT 连接到 Azure IotHub

php - 通过rabbitmq(amqp协议(protocol))从云端向设备物联网中心发送消息时遇到问题

azure - 如何从移动应用程序配置 Azure IoT 设备

python - 在 iot edge 模块中传递环境变量

azure - Azure IoT Edge 仪表板上的 "Connected Client Count"是什么

java - IoT 将数据包从设备发送到网络服务器

java - 如何在物联网边缘java模块中正确注册直接方法?

azure-functions - 如何在 Azure Functions 中的 EventHub 输出绑定(bind)上设置 systemProperties

java - azure iothub 设备状态

c - 了解 Azure IoT Edge 模块