Udostępnij za pośrednictwem


CosmosClientBuilder Constructors

Definition

Overloads

CosmosClientBuilder(String)

Extracts the account endpoint and key from the connection string.

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.

public CosmosClientBuilder (string connectionString);
new Azure.Cosmos.Fluent.CosmosClientBuilder : string -> Azure.Cosmos.Fluent.CosmosClientBuilder
Public Sub New (connectionString As String)

Parameters

connectionString
String

The connection string must contain AccountEndpoint and AccountKey or ResourceToken.

Examples

"AccountEndpoint=https://mytestcosmosaccount.documents.azure.com:443/;AccountKey={SecretAccountKey};"

Applies to

CosmosClientBuilder(String, String)

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

public CosmosClientBuilder (string accountEndpoint, string authKeyOrResourceToken);
new Azure.Cosmos.Fluent.CosmosClientBuilder : string * string -> Azure.Cosmos.Fluent.CosmosClientBuilder
Public Sub New (accountEndpoint As String, authKeyOrResourceToken As String)

Parameters

accountEndpoint
String

The Uri to the Cosmos Account. Example: https://{Cosmos Account Name}.documents.azure.com:443/

authKeyOrResourceToken
String

The key to the account or resource token.

Examples

The example below creates a new CosmosClientBuilder

CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder(
    accountEndpoint: "https://testcosmos.documents.azure.com:443/",
    authKeyOrResourceToken: "SuperSecretKey");
CosmosClient client = cosmosClientBuilder.Build();

The example below creates a new CosmosClientBuilder with a ConsistencyLevel and a list of preferred locations.

CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder(
    accountEndpoint: "https://testcosmos.documents.azure.com:443/",
    authKeyOrResourceToken: "SuperSecretKey")
.WithConsistencyLevel(ConsistencyLevel.Strong)
.WithApplicationRegion("East US 2");
CosmosClient client = cosmosClientBuilder.Build();

Applies to