azure - 如何从 Azure IoT 中心获取设备上的日期时间?

标签 azure azure-iot-hub

我需要更新一些通过 Azure IoT 中心连接到 Azure 的设备中的日期和时间。

有没有办法从 IoT 中心获取日期时间?

如何管理时区?

哪个时区将提供 Azure IoT 中心?

还有其他选择吗?

最佳答案

不知道 Azure IoT 中心中存在此类 API 接口(interface),但是,您的选项包括 -

  • 针对公共(public)时间服务器池 (pool.ntp.org) 使用 NTP。我会使用来自 NIST 或其他资金比 ntp-org 实体更好的主机 - https://tf.nist.gov/tf-cgi/servers.cgi
  • 编写一个 Azure 函数,该函数根据从设备发送的位置查询参数(GET 或 POST)返回日期/时间字符串。例如http://somethingSomething.azurewebsites.net/api/now?location=NewYork
  • 使用现成的公共(public) REST API,即 http://worldtimeapi.org/
  • 通过 HTTPS“滥用”您的 IoT 中心端点,即使对于 400 错误请求也会返回日期/时间,例如:

    $ curl https://poorlyfundedskynet.azure-devices.net -i
    
    HTTP/1.1 400 Bad Request
    Content-Length: 157
    ..snip other headers..
    Date: Wed, 11 Dec 2019 16:16:51 GMT
    

    注意:仅限 HTTPS。优点:您可以与同一位主持人讨论所有事情。缺点:无法保证时间戳准确,但其他所有服务也是如此。接受一点风险! :)

编辑:
链接到此relevant GitHub issue (在适用于 C 的 Azure IoT 中心客户端 SDK 下)。

关于azure - 如何从 Azure IoT 中心获取设备上的日期时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59289678/

相关文章:

reactjs - Microsoft Graph - React 客户端和 spring-boot 后端的 OAuth2.0 流程

Azure CDN : wildcard in rules engine

python - 出现错误 : [Errno 95] Operation not supported while writing zip file in databricks

azure - 如何在azure门户中配置多级虚拟目录?

azure - 节点红色 - 无法连接 : getaddrinfo ENOTFOUND xxx-device-hub. azure-devices.net”

Azure 流分析输入 Blob 存储动态路径模式

c# - 如果没有处理程序,Azure IoT 中心直接方法调用会发生什么情况

azure - 我是否能够使用 Azure IoT Edge 网关在叶设备和 Azure IoT 中心之间进行双向通信?

c# - Azure IoT Edge ModuleClient 调用另一个模块中的直接方法

azure - X509 配置需要什么设备才能将遥测数据发送到 IoTHub