DocumentClient.ReplaceAttachmentAsync Método

Definição

Sobrecargas

ReplaceAttachmentAsync(Attachment, RequestOptions, CancellationToken)

Substitui um Attachment no serviço do Azure Cosmos DB como uma operação assíncrona.

ReplaceAttachmentAsync(Uri, Attachment, RequestOptions, CancellationToken)

Substitui um anexo como uma operação assíncrona no serviço do Azure Cosmos DB.

ReplaceAttachmentAsync(Attachment, RequestOptions, CancellationToken)

Substitui um Attachment no serviço do Azure Cosmos DB como uma operação assíncrona.

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

Parâmetros

attachment
Attachment

O atualizado Attachment para substituir o recurso existente.

options
RequestOptions

(Opcional) As opções de solicitação para a solicitação.

cancellationToken
CancellationToken

(Opcional) Um CancellationToken que pode ser usado por outros objetos ou threads para receber notificação de cancelamento.

Retornos

Um System.Threading.Tasks que contém um ResourceResponse<TResource> que encapsula um Attachment que contém o registro de recurso atualizado.

Implementações

Exceções

Se attachment não estiver definido.

Essa exceção pode encapsular muitos tipos diferentes de erros. Para determinar o erro específico, sempre examine a propriedade StatusCode. Alguns códigos comuns que você pode obter ao criar um Documento são:

StatusCodeMotivo da exceção
404NotFound - Isso significa que o recurso que você tentou excluir não existia.

Exemplos

//Fetch the item to be updated
Attachment attachment = client.CreateAttachmentQuery(attachmentLink)
                            .Where(r => r.Id == "attachment id")
                            .AsEnumerable()
                            .SingleOrDefault();

//Update some properties on the found resource
attachment.MediaLink = "updated value";

//Now persist these changes to the database by replacing the original resource
Attachment updated = await client.ReplaceAttachmentAsync(attachment);

Confira também

Aplica-se a

ReplaceAttachmentAsync(Uri, Attachment, RequestOptions, CancellationToken)

Substitui um anexo como uma operação assíncrona no serviço do Azure Cosmos DB.

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

Parâmetros

attachmentUri
Uri

o URI do anexo a ser atualizado.

attachment
Attachment

o recurso de anexo.

options
RequestOptions

As opções de solicitação para a solicitação.

cancellationToken
CancellationToken

(Opcional) CancellationToken que representa o cancelamento da solicitação.

Retornos

O objeto de tarefa que representa a resposta de serviço para a operação assíncrona.

Implementações

Aplica-se a