Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CosmosClient: Adds CreateAndInitializeAsync Method #2197

Merged
merged 9 commits into from
Feb 17, 2021

Conversation

asketagarwal
Copy link
Contributor

@asketagarwal asketagarwal commented Feb 8, 2021

Pull Request Template

Description

Adds a CreateAndInitializeAsync method in CosmosClient. This creates a new client and initializes the containers provided by warming up the caches and connections
Closes: #1706

Sample

using Microsoft.Azure.Cosmos;
List<(string, string)> containersToInitialize = new List<(string, string)>
                                     { ("DatabaseName1", "ContainerName1"), ("DatabaseName2", "ContainerName2") };
CosmosClient cosmosClient = await CosmosClient.CreateAndInitializeAsync("account-endpoint-from-portal", 
                                                                               "account-key-from-portal",
                                                                                containersToInitialize)

ealsur
ealsur previously approved these changes Feb 10, 2021
Copy link
Member

@ealsur ealsur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left some questions and suggestions, non-blocking, but might be worth thinking about them.

#else
internal
#endif
static async Task<CosmosClient> CreateAndInitializeAsync(string accountEndpoint,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replicating one for each CTOR is good if we can avoid in future.

@VTR-AReed
Copy link

Hello, how would this work with the newly added Always Encrypted as .WithEncryption() returns a new client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CosmosClient Cold start
5 participants