Share via


DirectMethodsClient.InvokeAsync Method

Definition

Overloads

InvokeAsync(String, DirectMethodServiceRequest, CancellationToken)

Invokes a method on a device.

InvokeAsync(String, String, DirectMethodServiceRequest, CancellationToken)

Invokes a method on a module.

InvokeAsync(String, DirectMethodServiceRequest, CancellationToken)

Invokes a method on a device.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.Devices.DirectMethodClientResponse> InvokeAsync (string deviceId, Microsoft.Azure.Devices.DirectMethodServiceRequest directMethodRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member InvokeAsync : string * Microsoft.Azure.Devices.DirectMethodServiceRequest * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.DirectMethodClientResponse>
override this.InvokeAsync : string * Microsoft.Azure.Devices.DirectMethodServiceRequest * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.DirectMethodClientResponse>
Public Overridable Function InvokeAsync (deviceId As String, directMethodRequest As DirectMethodServiceRequest, Optional cancellationToken As CancellationToken = Nothing) As Task(Of DirectMethodClientResponse)

Parameters

deviceId
String

The device identifier for the target device.

directMethodRequest
DirectMethodServiceRequest

Parameters to execute a direct method on the device.

cancellationToken
CancellationToken

A cancellation token to cancel the operation.

Returns

The direct method response.

Exceptions

When the provided deviceId or directMethodRequest is null.

Thrown if the deviceId is empty or white space.

Thrown 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. For a complete list of possible error cases, see IotHubServiceErrorCode.

If the HTTP request fails due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

If the provided cancellationToken has requested cancellation.

Applies to

InvokeAsync(String, String, DirectMethodServiceRequest, CancellationToken)

Invokes a method on a module.

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

Parameters

deviceId
String

The device identifier for the target device.

moduleId
String

The module identifier for the target module.

directMethodRequest
DirectMethodServiceRequest

Parameters to execute a direct method on the module.

cancellationToken
CancellationToken

A cancellation token to cancel the operation.

Returns

The direct method response.

Exceptions

When the provided deviceId or moduleId or directMethodRequest is null.

Thrown if the deviceId or moduleId is empty or white space.

Thrown 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. For a complete list of possible error cases, see IotHubServiceErrorCode.

If the HTTP request fails due to an underlying issue such as network connectivity, DNS failure, or server certificate validation.

If the provided cancellationToken has requested cancellation.

Applies to