参考 - IoT 中心终结点Reference - IoT Hub endpoints


本文中提到的某些功能(例如云到设备消息传递、设备孪生、设备管理)仅在 IoT 中心的标准层中提供。Some of the features mentioned in this article, like cloud-to-device messaging, device twins, and device management, are only available in the standard tier of IoT hub. 有关基本和标准 IoT 中心层的详细信息,请参阅如何选择合适的 IoT 中心层For more information about the basic and standard IoT Hub tiers, see How to choose the right IoT Hub tier.

IoT 中心名称IoT Hub names

可在中心的“概述”页上找到在门户中托管终结点的 IoT 中心的主机名 。You can find the hostname of the IoT hub that hosts your endpoints in the portal on your hub's Overview page. 默认情况下,IoT 中心的 DNS 名称如下所示:{your iot hub name}.azure-devices.cnBy default, the DNS name of an IoT hub looks like: {your iot hub name}.azure-devices.cn.

内置 IoT 中心终结点列表List of built-in IoT Hub endpoints

Azure IoT 中心属于多租户服务,向各种执行组件公开功能。Azure IoT Hub is a multi-tenant service that exposes its functionality to various actors. 下图显示了 IoT 中心公开的各种终结点。The following diagram shows the various endpoints that IoT Hub exposes.

IoT 中心终结点

以下列表对这些终结点进行了说明:The following list describes the endpoints:

  • 资源提供程序Resource provider. IoT 中心资源提供程序公开一个 Azure 资源管理器接口。The IoT Hub resource provider exposes an Azure Resource Manager interface. 此接口使 Azure 订阅所有者可以创建和删除 IoT 中心以及更新 IoT 中心属性。This interface enables Azure subscription owners to create and delete IoT hubs, and to update IoT hub properties. IoT 中心属性可管理中心级别安全策略,而不是设备级别的访问控制以及云到设备和设备到云消息传送的功能选项。IoT Hub properties govern hub-level security policies, as opposed to device-level access control, and functional options for cloud-to-device and device-to-cloud messaging. IoT 中心资源提供程序还可让你导出设备标识The IoT Hub resource provider also enables you to export device identities.

  • 设备标识管理Device identity management. 每个 IoT 中心公开一组用于管理设备标识的 HTTPS REST 终结点(创建、检索、更新和删除)。Each IoT hub exposes a set of HTTPS REST endpoints to manage device identities (create, retrieve, update, and delete). 设备标识用于设备身份验证和访问控制。Device identities are used for device authentication and access control.

  • 设备孪生管理Device twin management. 每个 IoT 中心都会公开一组面向服务的 HTTPS REST 终结点,用于查询和更新设备孪生(更新标记和属性)。Each IoT hub exposes a set of service-facing HTTPS REST endpoint to query and update device twins (update tags and properties).

  • 作业管理Jobs management. 每个 IoT 中心都会公开一组面向服务的 HTTPS REST 终结点,用于查询和管理作业Each IoT hub exposes a set of service-facing HTTPS REST endpoint to query and manage jobs.

  • 设备终结点Device endpoints. 对于标识注册表中的每个设备,IoT 中心都会公开一组终结点。For each device in the identity registry, IoT Hub exposes a set of endpoints. 除非标明,否则这些终结点使用 MQTT v3.1.1、HTTPS 1.1 和 AMQP 1.0 协议进行公开。Except where noted, these endpoints are exposed using MQTT v3.1.1, HTTPS 1.1, and AMQP 1.0 protocols. 还可通过端口 443 上的 WebSocket 使用 AMQP 和 MQTT。AMQP and MQTT are also available over WebSockets on port 443.

    • 发送设备到云的消息Send device-to-cloud messages. 设备使用此终结点发送设备到云的消息A device uses this endpoint to send device-to-cloud messages.

    • 接收云到设备的消息Receive cloud-to-device messages. 设备使用此终结点接收目标云到设备的消息A device uses this endpoint to receive targeted cloud-to-device messages.

    • 启动文件上传Initiate file uploads. 设备使用此终结点接收来自 IoT 中心的 Azure 存储 SAS URI,以便上传文件A device uses this endpoint to receive an Azure Storage SAS URI from IoT Hub to upload a file.

    • 检索并更新设备孪生的属性Retrieve and update device twin properties. 设备使用此终结点访问其设备孪生的属性。A device uses this endpoint to access its device twin's properties. 不支持 HTTPS。HTTPS is not supported.

    • 接收直接方法请求Receive direct method requests. 设备使用此终结点侦听直接方法的请求。A device uses this endpoint to listen for direct method's requests. 不支持 HTTPS。HTTPS is not supported.

  • 服务终结点Service endpoints. 每个 IoT 中心公开一组终结点,供解决方案后端用于与设备通信。Each IoT hub exposes a set of endpoints for your solution back end to communicate with your devices. 除了一个例外,这些终结点只使用 AMQP 协议以及基于 WebSockets 的 AMQP 协议进行公开。With one exception, these endpoints are only exposed using the AMQP and AMQP over WebSockets protocols. 直接方法调用终结点通过 HTTPS 协议进行公开。The direct method invocation endpoint is exposed over the HTTPS protocol.

    • 接收设备到云的消息Receive device-to-cloud messages. 此终结点与 Azure 事件中心兼容。This endpoint is compatible with Azure Event Hubs. 后端服务可用它来读取由设备发送的设备到云的消息A back-end service can use it to read the device-to-cloud messages sent by your devices. 除了此内置终结点外,还可以在 IoT 中心创建自定义终结点。You can create custom endpoints on your IoT hub in addition to this built-in endpoint.

    • 发送云到设备的消息并接收传递确认Send cloud-to-device messages and receive delivery acknowledgments. 这些终结点可让解决方案后端发送可靠的云到设备的消息,以及接收对应的传送或过期确认。These endpoints enable your solution back end to send reliable cloud-to-device messages, and to receive the corresponding delivery or expiration acknowledgments.

    • 接收文件通知Receive file notifications. 此消息传递终结点允许在设备成功上传文件时接收通知。This messaging endpoint allows you to receive notifications of when your devices successfully upload a file.

    • 直接方法调用Direct method invocation. 此终结点允许后端服务在设备上调用直接方法This endpoint allows a back-end service to invoke a direct method on a device.

    • 接收操作监视事件Receive operations monitoring events. 此终结点可以用于接收操作监视事件,前提是已将 IoT 中心配置为发出这些事件。This endpoint allows you to receive operations monitoring events if your IoT hub has been configured to emit them. 有关详细信息,请参阅 IoT 中心操作监视For more information, see IoT Hub operations monitoring.

Azure IoT SDK 一文介绍了访问这些终结点的各种方法。The Azure IoT SDKs article describes the various ways to access these endpoints.

所有 IoT 中心终结点都使用 TLS 协议,且绝不会在未加密/不安全的通道上公开任何终结点。All IoT Hub endpoints use the TLS protocol, and no endpoint is ever exposed on unencrypted/unsecured channels.

自定义终结点Custom endpoints

可将订阅中的现有 Azure 服务链接到用作消息路由终结点的 IoT 中心。You can link existing Azure services in your subscription to your IoT hub to act as endpoints for message routing. 这些终结点充当服务终结点,并用作消息路由的接收器。These endpoints act as service endpoints and are used as sinks for message routes. 设备无法直接写入附加终结点。Devices cannot write directly to the additional endpoints. 详细了解消息路由Learn more about message routing.

IoT 中心当前支持将以下 Azure 服务作为附加终结点:IoT Hub currently supports the following Azure services as additional endpoints:

  • Azure 存储容器Azure Storage containers
  • 事件中心Event Hubs
  • 服务总线队列Service Bus Queues
  • 服务总线主题Service Bus Topics

有关可添加的终结点的数量限制,请参阅配额和限制For the limits on the number of endpoints you can add, see Quotas and throttling.

终结点运行状况Endpoint Health

可以使用 REST API Get Endpoint Health 获取终结点的运行状况状态。You can use the REST API Get Endpoint Health to get health status of the endpoints. 我们建议使用与路由消息延迟相关的 IoT 中心指标来识别和调试终结点运行状况不佳或运行不正常时的错误,因为我们预计当终结点处于其中一种状态时,延迟会更高。We recommend using the IoT Hub metrics related to routing message latency to identify and debug errors when endpoint health is dead or unhealthy, as we expect latency to be higher when the endpoint is in one of those states.

运行状况状态Health Status 说明Description
healthyhealthy 终结点按预期方式接受消息。The endpoint is accepting messages as expected.
不正常unhealthy 终结点未接受消息,IoT 中心正重试将消息发送到此终结点。The endpoint is not accepting messages and IoT Hub is retrying to send messages to this endpoint.
未知unknown IoT 中心尚未尝试将消息传递到此终结点。IoT Hub has not attempted to deliver messages to this endpoint.
已降级degraded 终结点正在接受比预期慢的消息或正在从不正常状态恢复。The endpoint is accepting messages slower than expected or is recovering from an unhealthy state.
不活动dead IoT 中心不再向此终结点传递消息。IoT Hub is no longer delivering messages to this endpoint. 重新尝试将消息发送到此终结点时失败。Retries to send messages to this endpoint failed.

现场网关Field gateways

在 IoT 解决方案中, 现场网关 位于设备和 IoT 中心终结点之间。In an IoT solution, a field gateway sits between your devices and your IoT Hub endpoints. 它通常位于靠近设备的位置。It is typically located close to your devices. 设备使用设备支持的协议,直接与现场网关通信。Your devices communicate directly with the field gateway by using a protocol supported by the devices. 现场网关使用 IoT 中心支持的协议连接到 IoT 中心终结点。The field gateway connects to an IoT Hub endpoint using a protocol that is supported by IoT Hub. 现场网关可能是专用硬件设备或运行自定义网关软件的低功率计算机。A field gateway might be a dedicated hardware device or a low-power computer running custom gateway software.

可使用 Azure IoT Edge 实现现场网关。You can use Azure IoT Edge to implement a field gateway. IoT Edge 提供一些功能,例如从多台设备向同一 IoT 中心连接多路复用通信。IoT Edge offers functionality such as multiplexing communications from multiple devices onto the same IoT Hub connection.

后续步骤Next steps

此 IoT 中心开发人员指南中的其他参考主题包括:Other reference topics in this IoT Hub developer guide include: