Table of Contents

Class ContainerBuilder

Namespace
Microsoft.Azure.Cosmos.Fluent
Assembly
Microsoft.Azure.Cosmos.Client.dll

Container fluent definition for creation flows.

public class ContainerBuilder : ContainerDefinition<ContainerBuilder>
Inheritance
ContainerBuilder
Inherited Members
Extension Methods

Constructors

ContainerBuilder()

Creates an instance for unit-testing

protected ContainerBuilder()

ContainerBuilder(Database, string, string)

Creates an instance of ContainerBuilder .

public ContainerBuilder(Database database, string name, string partitionKeyPath)

Parameters

database Database

The Microsoft.Azure.Cosmos.Database object.

name string

Azure Cosmos container name to create.

partitionKeyPath string

The path to the partition key. Example: /partitionKey

Methods

Build()

Applies the current Fluent definition and creates a container configuration.

public ContainerProperties Build()

Returns

ContainerProperties

Builds the current Fluent configuration into an instance of ContainerProperties.

CreateAsync(ThroughputProperties, CancellationToken)

Creates a container with the current fluent definition.

public Task<ContainerResponse> CreateAsync(ThroughputProperties throughputProperties, CancellationToken cancellationToken = default)

Parameters

throughputProperties ThroughputProperties

Desired throughput for the container expressed in Request Units per second.

cancellationToken CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

Task<ContainerResponse>

An asynchronous Task representing the creation of a Container based on the Fluent definition.

See Also

CreateAsync(int?, CancellationToken)

Creates a container with the current fluent definition.

public Task<ContainerResponse> CreateAsync(int? throughput = null, CancellationToken cancellationToken = default)

Parameters

throughput int?

Desired throughput for the container expressed in Request Units per second.

cancellationToken CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

Task<ContainerResponse>

An asynchronous Task representing the creation of a Container based on the Fluent definition.

See Also

CreateIfNotExistsAsync(ThroughputProperties, CancellationToken)

Creates a container if it does not exist with the current fluent definition.

public Task<ContainerResponse> CreateIfNotExistsAsync(ThroughputProperties throughputProperties, CancellationToken cancellationToken = default)

Parameters

throughputProperties ThroughputProperties

Desired throughput for the container expressed in Request Units per second.

cancellationToken CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

Task<ContainerResponse>

An asynchronous Task representing the creation of a Container based on the Fluent definition.

See Also

CreateIfNotExistsAsync(int?, CancellationToken)

Creates a container if it does not exist with the current fluent definition.

public Task<ContainerResponse> CreateIfNotExistsAsync(int? throughput = null, CancellationToken cancellationToken = default)

Parameters

throughput int?

Desired throughput for the container expressed in Request Units per second.

cancellationToken CancellationToken

(Optional) CancellationToken representing request cancellation.

Returns

Task<ContainerResponse>

An asynchronous Task representing the creation of a Container based on the Fluent definition.

See Also

WithClientEncryptionPolicy()

Defines the ClientEncryptionPolicy for Azure Cosmos container. The PolicyFormatVersion will be set to 1. Note: If you need to include partition key or id field paths as part of ClientEncryptionPolicy, please set PolicyFormatVersion to 2.

public ClientEncryptionPolicyDefinition WithClientEncryptionPolicy()

Returns

ClientEncryptionPolicyDefinition

An instance of ClientEncryptionPolicyDefinition.

WithClientEncryptionPolicy(int)

Defines the ClientEncryptionPolicy for Azure Cosmos container Note: If you need to include partition key or id field paths as part of ClientEncryptionPolicy, please set PolicyFormatVersion to 2.

public ClientEncryptionPolicyDefinition WithClientEncryptionPolicy(int policyFormatVersion)

Parameters

policyFormatVersion int

Version of the client encryption policy definition. Current supported versions are 1 and 2.

Returns

ClientEncryptionPolicyDefinition

An instance of ClientEncryptionPolicyDefinition.

WithConflictResolution()

Defined the conflict resolution for Azure Cosmos container

public ConflictResolutionDefinition WithConflictResolution()

Returns

ConflictResolutionDefinition

An instance of ConflictResolutionDefinition.

WithUniqueKey()

Defines a Unique Key policy for this Azure Cosmos container.

public UniqueKeyDefinition WithUniqueKey()

Returns

UniqueKeyDefinition

An instance of UniqueKeyDefinition.