Share via


MessagesClient.PurgeMessageQueueAsync(String, CancellationToken) Method

Definition

Removes all cloud-to-device messages from a device's queue.

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

Parameters

deviceId
String

The device identifier for the target device.

cancellationToken
CancellationToken

A cancellation token to cancel the operation.

Returns

The PurgeMessageQueueResult.

Exceptions

When the provided deviceId is null.

If the deviceId is empty or white space.

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

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.

Remarks

This call is made over HTTP. There is no need to call OpenAsync(CancellationToken) before calling this method.

Applies to