DevicesClient.DeleteAsync Method

Definition

Overloads

DeleteAsync(String, CancellationToken)

Delete the device identity with the provided Id from your IoT hub's registry.

DeleteAsync(Device, Boolean, CancellationToken)

Delete the device identity with the provided Id from your IoT hub's registry.

DeleteAsync(IEnumerable<Device>, Boolean, CancellationToken)

Delete up to 100 device identities from your IoT hub's registry in bulk.

DeleteAsync(String, CancellationToken)

Delete the device identity with the provided Id from your IoT hub's registry.

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

Parameters

deviceId
String

The Id of the device identity to be deleted.

cancellationToken
CancellationToken

The token which allows the operation to be canceled.

Returns

Exceptions

When the provided device Id is null.

When the provided device Id 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. 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 cancellation token has requested cancellation.

Applies to

DeleteAsync(Device, Boolean, CancellationToken)

Delete the device identity with the provided Id from your IoT hub's registry.

public virtual System.Threading.Tasks.Task DeleteAsync (Microsoft.Azure.Devices.Device device, bool onlyIfUnchanged = false, System.Threading.CancellationToken cancellationToken = default);
abstract member DeleteAsync : Microsoft.Azure.Devices.Device * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.DeleteAsync : Microsoft.Azure.Devices.Device * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function DeleteAsync (device As Device, Optional onlyIfUnchanged As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

device
Device

The device identity to delete from your IoT hub's registry. If the provided device's ETag is out of date, this operation will throw a IotHubServiceException with PreconditionFailed An up-to-date ETag can be retrieved using GetAsync(String, CancellationToken). To force the operation to execute regardless of ETag, set the device identity's ETag to "*" or use DeleteAsync(String, CancellationToken).

onlyIfUnchanged
Boolean

If false, this delete operation will be performed even if the provided device identity has an out of date ETag. If true, the operation will throw a IotHubServiceException with PreconditionFailed if the provided device identity has an out of date ETag. An up-to-date ETag can be retrieved using GetAsync(String, CancellationToken).

cancellationToken
CancellationToken

The token which allows the operation to be canceled.

Returns

Exceptions

When the provided device is null.

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 cancellation token has requested cancellation.

Applies to

DeleteAsync(IEnumerable<Device>, Boolean, CancellationToken)

Delete up to 100 device identities from your IoT hub's registry in bulk.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.Devices.BulkRegistryOperationResult> DeleteAsync (System.Collections.Generic.IEnumerable<Microsoft.Azure.Devices.Device> devices, bool onlyIfUnchanged = false, System.Threading.CancellationToken cancellationToken = default);
abstract member DeleteAsync : seq<Microsoft.Azure.Devices.Device> * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.BulkRegistryOperationResult>
override this.DeleteAsync : seq<Microsoft.Azure.Devices.Device> * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Devices.BulkRegistryOperationResult>
Public Overridable Function DeleteAsync (devices As IEnumerable(Of Device), Optional onlyIfUnchanged As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of BulkRegistryOperationResult)

Parameters

devices
IEnumerable<Device>

The device identities to delete from your IoT hub's registry. May not exceed 100 devices.

onlyIfUnchanged
Boolean

If false, this delete operation will be performed even if the provided device identity has an out of date ETag. If true, the operation will throw a IotHubServiceException with PreconditionFailed if the provided device identity has an out of date ETag. An up-to-date ETag can be retrieved using GetAsync(String, CancellationToken).

cancellationToken
CancellationToken

The token which allows the operation to be canceled.

Returns

The result of the bulk operation.

Exceptions

When the provided device collection is null.

When the provided device collection is empty.

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 cancellation token has requested cancellation.

Applies to