你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

MessagesClient.SendAsync 方法

定义

重载

SendAsync(String, Message, CancellationToken)

将云到设备的消息发送到指定的设备。

SendAsync(String, String, Message, CancellationToken)

将云到设备的消息发送到指定的模块。

SendAsync(String, Message, CancellationToken)

将云到设备的消息发送到指定的设备。

public virtual System.Threading.Tasks.Task SendAsync (string deviceId, Microsoft.Azure.Devices.Message message, System.Threading.CancellationToken cancellationToken = default);
abstract member SendAsync : string * Microsoft.Azure.Devices.Message * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.SendAsync : string * Microsoft.Azure.Devices.Message * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function SendAsync (deviceId As String, message As Message, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

deviceId
String

目标设备的设备标识符。

message
Message

云到设备的消息。

cancellationToken
CancellationToken

任务取消标记。

返回

例外

当提供的 deviceIdmessage 为 null 时。

如果提供的 deviceId 为空或空格。

如果 IoT 中心使用未成功状态代码响应请求。 例如,如果提供的请求受到限制, IotHubServiceException 则会引发 和 ThrottlingException

如果提供的 cancellationToken 已请求取消。

注解

若要在服务客户端上接收反馈消息,请将 Ack 属性设置为适当的值并使用 MessageFeedback

适用于

SendAsync(String, String, Message, CancellationToken)

将云到设备的消息发送到指定的模块。

public virtual System.Threading.Tasks.Task SendAsync (string deviceId, string moduleId, Microsoft.Azure.Devices.Message message, System.Threading.CancellationToken cancellationToken = default);
abstract member SendAsync : string * string * Microsoft.Azure.Devices.Message * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.SendAsync : string * string * Microsoft.Azure.Devices.Message * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function SendAsync (deviceId As String, moduleId As String, message As Message, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

deviceId
String

目标设备的设备标识符。

moduleId
String

目标模块的模块标识符。

message
Message

云到模块的消息。

cancellationToken
CancellationToken

任务取消标记。

返回

例外

当提供的 deviceIdmoduleIdmessage 为 null 时。

如果提供的 deviceIdmoduleId 为空或空格。

如果 IoT 中心使用未成功状态代码响应请求。 例如,如果提供的请求受到限制, IotHubServiceException 则会引发 和 ThrottlingException

如果提供的 cancellationToken 已请求取消。

适用于