CosmosClientBuilder.BuildAndInitializeAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A method to create the cosmos client and initialize the provided containers. In addition to that it initializes the client with containers provided i.e The SDK warms up the caches and connections before the first call to the service is made. Use this to obtain lower latency while startup of your application. CosmosClient is thread-safe. Its recommended to maintain a single instance of CosmosClient per lifetime of the application which enables efficient connection management and performance. Please refer to the performance guide.
public System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.CosmosClient> BuildAndInitializeAsync (System.Collections.Generic.IReadOnlyList<(string databaseId, string containerId)> containers, System.Threading.CancellationToken cancellationToken = default);
member this.BuildAndInitializeAsync : System.Collections.Generic.IReadOnlyList<ValueTuple<string, string>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.Cosmos.CosmosClient>
Public Function BuildAndInitializeAsync (containers As IReadOnlyList(Of ValueTuple(Of String, String)), Optional cancellationToken As CancellationToken = Nothing) As Task(Of CosmosClient)
Parameters
- containers
- IReadOnlyList<ValueTuple<String,String>>
Containers to be initialized identified by it's database name and container name.
- cancellationToken
- CancellationToken
(Optional) Cancellation Token
Returns
A CosmosClient object.
Applies to
Azure SDK for .NET