次の方法で共有


CosmosContainer.CreateItemStreamAsync メソッド

定義

Azure Cosmos サービスで非同期操作として Item を作成します。

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

パラメーター

streamPayload
Stream

Streamペイロードを含む 。

partitionKey
PartitionKey

項目のパーティション キー。 PartitionKey

requestOptions
ItemRequestOptions

(省略可能)アイテム要求のオプション ItemRequestOptions

cancellationToken
CancellationToken

(省略可能) CancellationToken 要求の取り消しを表します。

戻り値

非同期操作の Response サービス応答を Task 表す オブジェクト内に含まれる 作成された 。

次の使用例は、Cosmos コンテナーに項目を作成します。

//Create the object in Cosmos
using (Response response = await this.Container.CreateItemStreamAsync(partitionKey: new PartitionKey("streamPartitionKey"), streamPayload: stream))
{

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

適用対象