Share via


Container.PatchItemStreamAsync Method

Definition

Patches an item in the Azure Cosmos service as an asynchronous operation.

public abstract System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ResponseMessage> PatchItemStreamAsync (string id, Microsoft.Azure.Cosmos.PartitionKey partitionKey, System.Collections.Generic.IReadOnlyList<Microsoft.Azure.Cosmos.PatchOperation> patchOperations, Microsoft.Azure.Cosmos.PatchItemRequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member PatchItemStreamAsync : string * Microsoft.Azure.Cosmos.PartitionKey * System.Collections.Generic.IReadOnlyList<Microsoft.Azure.Cosmos.PatchOperation> * Microsoft.Azure.Cosmos.PatchItemRequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.ResponseMessage>
Public MustOverride Function PatchItemStreamAsync (id As String, partitionKey As PartitionKey, patchOperations As IReadOnlyList(Of PatchOperation), Optional requestOptions As PatchItemRequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ResponseMessage)

Parameters

id
String

The Cosmos item id

partitionKey
PartitionKey

The partition key for the item.

patchOperations
IReadOnlyList<PatchOperation>

Represents a list of operations to be sequentially applied to the referred Cosmos item.

requestOptions
PatchItemRequestOptions

(Optional) The options for the item request.

cancellationToken
CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

A Task containing a ResponseMessage which wraps a Stream containing the patched resource record.

Examples

PatchItemAsync<T>(String, PartitionKey, IReadOnlyList<PatchOperation>, PatchItemRequestOptions, CancellationToken)

Remarks

The item's partition key value is immutable. To change an item's partition key value you must delete the original item and insert a new item. The patch operations are atomic and are executed sequentially. By default, resource body will be returned as part of the response. User can request no content by setting EnableContentResponseOnWrite flag to false.

Applies to