Udostępnij za pośrednictwem


MessagesClient.SendAsync Method

Definition

Overloads

SendAsync(String, Message, CancellationToken)

Send a cloud-to-device message to the specified device.

SendAsync(String, String, Message, CancellationToken)

Send a cloud-to-device message to the specified module.

SendAsync(String, Message, CancellationToken)

Send a cloud-to-device message to the specified device.

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

Parameters

deviceId
String

The device identifier for the target device.

message
Message

The cloud-to-device message.

cancellationToken
CancellationToken

Task cancellation token.

Returns

Exceptions

When the provided deviceId or message is null.

If the provided deviceId is empty or whitespace.

If IoT hub responded to the request with a non-successful status code. For example, if the provided request was throttled, IotHubServiceException with ThrottlingException is thrown.

If the provided cancellationToken has requested cancellation.

Remarks

In order to receive feedback messages on the service client, set the Ack property to an appropriate value and use MessageFeedback.

Applies to

SendAsync(String, String, Message, CancellationToken)

Send a cloud-to-device message to the specified module.

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

Parameters

deviceId
String

The device identifier for the target device.

moduleId
String

The module identifier for the target module.

message
Message

The cloud-to-module message.

cancellationToken
CancellationToken

Task cancellation token.

Returns

Exceptions

When the provided deviceId or moduleId or message is null.

If the provided deviceId or moduleId is empty or whitespace.

If IoT hub responded to the request with a non-successful status code. For example, if the provided request was throttled, IotHubServiceException with ThrottlingException is thrown.

If the provided cancellationToken has requested cancellation.

Applies to