Share via


CosmosDatabase.CreateContainerStreamAsync Method

Definition

Creates a container as an asynchronous operation in the Azure Cosmos service.

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)

Parameters

containerProperties
ContainerProperties

The ContainerProperties object.

throughput
Nullable<Int32>

(Optional) The throughput provisioned for a container in measurement of Request Units per second in the Azure Cosmos DB service.

requestOptions
RequestOptions

(Optional) The options for the container request RequestOptions

cancellationToken
CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

A Task containing a Response containing the created resource record.

Examples

Creates a container as an asynchronous operation in the Azure Cosmos service and return stream response.

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

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

Remarks

https://docs.microsoft.com/azure/cosmos-db/request-units for details on provision throughput.

Applies to