Created
April 16, 2021 17:56
-
-
Save ealsur/01b99715c98e11a6bd0ce7c4ea5e80dd to your computer and use it in GitHub Desktop.
Create and initialize CosmosClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<(string, string)> containers = new List<(string, string)> | |
{ | |
("DatabaseNameForContainer1", "ContainerName1"), | |
("DatabaseNameForContainer2", "ContainerName2") | |
}; | |
CosmosClientOptions cosmosClientOptions = new CosmosClientOptions | |
{ | |
ApplicationName = "MyApplicationName", | |
// any other setting I want to customize | |
}; | |
CosmosClient cosmosClient = await CosmosClient.CreateAndInitializeAsync(connectionString, containers, cosmosClientOptions); |
This is kind of getting to my point with the post :)
If you try that code you see that you don't have access to the serviceProvider at that stage.
I understand that my question might be tricky to solve, but at least to me, this looks like a pretty normal setup of a client.
I see what you mean, you cannot read the config because in your case it comes from serviceProvider
.
I've seen cases from it coming from the Configuration, which is built before the services are added (so it's available there).
Yes, I went with that option instead. That works too :)
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can build the client before?