DocumentClient.DeleteDocumentAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
DeleteDocumentAsync(String, RequestOptions, CancellationToken) |
Delete a Document from the Azure Cosmos DB service as an asynchronous operation. |
DeleteDocumentAsync(Uri, RequestOptions, CancellationToken) |
Delete a document as an asynchronous operation from the Azure Cosmos DB service. |
DeleteDocumentAsync(String, RequestOptions, CancellationToken)
Delete a Document from the Azure Cosmos DB service as an asynchronous operation.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Document>> DeleteDocumentAsync (string documentLink, Microsoft.Azure.Documents.Client.RequestOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DeleteDocumentAsync : string * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Document>>
override this.DeleteDocumentAsync : string * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Document>>
Public Function DeleteDocumentAsync (documentLink As String, Optional options As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceResponse(Of Document))
Parameters
- options
- RequestOptions
(Optional) The request options for the request.
- cancellationToken
- CancellationToken
(Optional) A CancellationToken that can be used by other objects or threads to receive notice of cancellation.
Returns
A System.Threading.Tasks containing a ResourceResponse<TResource> which will contain information about the request issued.
Implements
Exceptions
If documentLink
is not set.
This exception can encapsulate many different types of errors. To determine the specific error always look at the StatusCode property. Some common codes you may get when creating a Document are:
StatusCode | Reason for exception |
---|---|
404 | NotFound - This means the resource you tried to delete did not exist. |
Examples
//Delete a document using its selfLink property
//To get the documentLink you would have to query for the Document, using CreateDocumentQuery(), and then refer to its .SelfLink property
await client.DeleteDocumentAsync(documentLink);
See also
Applies to
DeleteDocumentAsync(Uri, RequestOptions, CancellationToken)
Delete a document as an asynchronous operation from the Azure Cosmos DB service.
public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Document>> DeleteDocumentAsync (Uri documentUri, Microsoft.Azure.Documents.Client.RequestOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DeleteDocumentAsync : Uri * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Document>>
override this.DeleteDocumentAsync : Uri * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Document>>
Public Function DeleteDocumentAsync (documentUri As Uri, Optional options As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceResponse(Of Document))
Parameters
- documentUri
- Uri
the URI of the document to delete.
- options
- RequestOptions
The request options for the request.
- cancellationToken
- CancellationToken
(Optional) CancellationToken representing request cancellation.
Returns
The task object representing the service response for the asynchronous operation.
Implements
Applies to
Azure SDK for .NET