共用方式為


IDocumentClient.DeleteAttachmentAsync Method

Definition

Overloads

DeleteAttachmentAsync(String, RequestOptions, CancellationToken)

Delete an Attachment from the the Azure Cosmos DB service as an asynchronous operation.

DeleteAttachmentAsync(Uri, RequestOptions, CancellationToken)

Delete an attachment as an asynchronous operation in the Azure Cosmos DB service.

DeleteAttachmentAsync(String, RequestOptions, CancellationToken)

Delete an Attachment from the the Azure Cosmos DB service as an asynchronous operation.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>> DeleteAttachmentAsync (string attachmentLink, Microsoft.Azure.Documents.Client.RequestOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DeleteAttachmentAsync : string * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>>
Public Function DeleteAttachmentAsync (attachmentLink As String, Optional options As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceResponse(Of Attachment))

Parameters

attachmentLink
String

The link of the Attachment to delete. E.g. dbs/db_rid/colls/col_rid/docs/doc_rid/attachments/attachment_rid/

options
RequestOptions

(Optional) Any options you wish to set for this request.

cancellationToken
CancellationToken

(Optional) A CancellationToken that can be used by other objects or threads to receive notice of cancellation.

Returns

Exceptions

If attachmentLink 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:

StatusCodeReason for exception
404NotFound - This means the resource you tried to delete did not exist.

Examples

//Delete an attachment using its selfLink property
//To get the attachmentLink you would have to query for the Attachment, using CreateAttachmentQuery(),  and then refer to its .SelfLink property
await client.DeleteAttachmentAsync(attachmentLink);

See also

Applies to

DeleteAttachmentAsync(Uri, RequestOptions, CancellationToken)

Delete an attachment as an asynchronous operation in the Azure Cosmos DB service.

public System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>> DeleteAttachmentAsync (Uri attachmentUri, Microsoft.Azure.Documents.Client.RequestOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DeleteAttachmentAsync : Uri * Microsoft.Azure.Documents.Client.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Documents.Client.ResourceResponse<Microsoft.Azure.Documents.Attachment>>
Public Function DeleteAttachmentAsync (attachmentUri As Uri, Optional options As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResourceResponse(Of Attachment))

Parameters

attachmentUri
Uri

The URI of the attachment to delete.

options
RequestOptions

(Optional) The RequestOptions for the request.

cancellationToken
CancellationToken

(Optional) A CancellationToken that can be used by other objects or threads to receive notice of cancellation.

Returns

The task object representing the service response for the asynchronous operation.

Applies to