使用 IoT 中心发送设备到云和云到设备的消息Send device-to-cloud and cloud-to-device messages with IoT Hub

IoT 中心支持与设备进行双向通信。IoT Hub allows for bi-directional communication with your devices. 使用 IoT 中心消息与设备进行通信,方法是:将消息从设备发送到解决方案后端,以及将命令从 IoT 解决方案后端发送到设备。Use IoT Hub messaging to communicate with your devices by sending messages from your devices to your solutions back end and sending commands from your IoT solutions back end to your devices. 了解有关 IoT 中心消息格式的详细信息。Learn more about the IoT Hub message format.

将设备到云的消息发送到 IoT 中心Sending device-to-cloud messages to IoT Hub

IoT 中心具有内置服务终结点,后端服务可以使用该终结点从设备中读取遥测消息。IoT Hub has a built-in service endpoint that can be used by back-end services to read telemetry messages from your devices. 此终结点与事件中心兼容,你可以使用标准 IoT 中心 SDK 从该内置终结点读取This endpoint is compatible with Event Hubs and you can use standard IoT Hub SDKs to read from this built-in endpoint.

IoT 中心还支持用户可定义的自定义终结点使用消息路由将设备遥测数据和事件发送到 Azure 服务。IoT Hub also supports custom endpoints that can be defined by users to send device telemetry data and events to Azure services using message routing.

从 IoT 中心发送云到设备的消息Sending cloud-to-device messages from IoT Hub

可以将云到设备的消息从解决方案后端发送到设备。You can send cloud-to-device messages from the solution back end to your devices.

Note

本文中提到的某些功能(例如云到设备消息传递、设备孪生、设备管理)仅在 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 中心消息传送功能的核心属性是消息的可靠性和持久性。Core properties of IoT Hub messaging functionality are the reliability and durability of messages. 这些属性可在设备端上恢复间歇性连接,以及在云恢复事件处理的负载高峰。These properties enable resilience to intermittent connectivity on the device side, and to load spikes in event processing on the cloud side. IoT 中心对从设备到云和从云到设备的消息传送实施至少一次传送保证。IoT Hub implements at least once delivery guarantees for both device-to-cloud and cloud-to-device messaging.

选择适当类型的 IoT 中心消息传递Choosing the right type of IoT Hub messaging

使用设备到云消息从设备应用发送时序遥测数据和警报,使用云到设备消息向设备应用发送单向通知。Use device-to-cloud messages for sending time series telemetry and alerts from your device app, and cloud-to-device messages for one-way notifications to your device app.

后续步骤Next steps