Share via


CosmosClientBuilder Class

Definition

This is a Builder class that creates a cosmos client

public class CosmosClientBuilder
type CosmosClientBuilder = class
Public Class CosmosClientBuilder
Inheritance
CosmosClientBuilder

Constructors

CosmosClientBuilder(String, String)

Initialize a new CosmosConfiguration class that holds all the properties the CosmosClient requires.

CosmosClientBuilder(String)

Extracts the account endpoint and key from the connection string.

Methods

Build()

A method to create the cosmos client

WithApplicationName(String)

A suffix to be added to the default user-agent for the Azure Cosmos DB service.

WithApplicationRegion(String)

Set the preferred geo-replicated region to be used in the Azure Cosmos DB service.

WithConnectionModeDirect()

Sets the connection mode to Direct. This is used by the client when connecting to the Azure Cosmos DB service.

WithConnectionModeGateway(Nullable<Int32>, IWebProxy)

Sets the connection mode to Gateway. This is used by the client when connecting to the Azure Cosmos DB service.

WithConsistencyLevel(ConsistencyLevel)

This can be used to weaken the database account consistency level for read operations. If this is not set the database account consistency level will be used for all requests.

WithCustomSerializer(CosmosSerializer)

Set a custom JSON serializer.

WithLimitToEndpoint(Boolean)

Limits the operations to the provided endpoint on the CosmosClientBuilder constructor.

WithRequestTimeout(TimeSpan)

Sets the request timeout in seconds when connecting to the Azure Cosmos DB service.

WithSerializerOptions(CosmosSerializationOptions)

Set a custom serializer option.

WithThrottlingRetryOptions(TimeSpan, Int32)

Sets the minimum time to wait between retry and the max number of times to retry on throttled requests.

Applies to