Partager via


CosmosContainer.UpsertItemStreamAsync Méthode

Définition

Upserts un flux d’éléments en tant qu’opération asynchrone dans le service Azure Cosmos.

public abstract System.Threading.Tasks.Task<Azure.Response> UpsertItemStreamAsync (System.IO.Stream streamPayload, Azure.Cosmos.PartitionKey partitionKey, Azure.Cosmos.ItemRequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member UpsertItemStreamAsync : System.IO.Stream * Azure.Cosmos.PartitionKey * Azure.Cosmos.ItemRequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
Public MustOverride Function UpsertItemStreamAsync (streamPayload As Stream, partitionKey As PartitionKey, Optional requestOptions As ItemRequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response)

Paramètres

streamPayload
Stream

Stream contenant la charge utile.

partitionKey
PartitionKey

Clé de partition de l’élément. PartitionKey

requestOptions
ItemRequestOptions

(Facultatif) Options de la demande d’élément ItemRequestOptions

cancellationToken
CancellationToken

(Facultatif) CancellationToken représentant l’annulation de la demande.

Retours

Task contenant un Response qui encapsule un Stream contenant l’enregistrement de ressource de lecture.

Exemples

Upsert a Stream contenant l’élément vers Cosmos

using(Response response = await this.container.UpsertItemStreamAsync(stream, new PartitionKey("itemPartitionKey")))
{

    using(Stream stream = response.ContentStream)
    {
        //Read or do other operations with the stream
        using (StreamReader  streamReader = new StreamReader(stream))
        {
            string content =  streamReader.ReadToEndAsync();
        }
    }
}

S’applique à