你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

CosmosDatabase.CreateContainerStreamAsync 方法

定义

在 Azure Cosmos 服务中将容器创建为异步操作。

public abstract System.Threading.Tasks.Task<Azure.Response> CreateContainerStreamAsync (Azure.Cosmos.ContainerProperties containerProperties, int? throughput = default, Azure.Cosmos.RequestOptions requestOptions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateContainerStreamAsync : Azure.Cosmos.ContainerProperties * Nullable<int> * Azure.Cosmos.RequestOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
Public MustOverride Function CreateContainerStreamAsync (containerProperties As ContainerProperties, Optional throughput As Nullable(Of Integer) = Nothing, Optional requestOptions As RequestOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response)

参数

containerProperties
ContainerProperties

ContainerProperties 对象。

throughput
Nullable<Int32>

(可选) 为容器预配的吞吐量,以度量 Azure Cosmos DB 服务中的每秒请求单位数。

requestOptions
RequestOptions

(可选) 容器请求的选项 RequestOptions

cancellationToken
CancellationToken

(表示请求取消的可选) CancellationToken

返回

包含TaskResponse所创建资源记录的 。

示例

在 Azure Cosmos 服务中创建一个容器作为异步操作,并返回流响应。

ContainerProperties containerProperties = new ContainerProperties()
{
    Id = Guid.NewGuid().ToString(),
    PartitionKeyPath = "/pk",
};

using(Response response = await this.cosmosDatabase.CreateContainerStreamAsync(containerProperties))
{
}

注解

https://docs.microsoft.com/azure/cosmos-db/request-units 有关预配吞吐量的详细信息。

适用于