You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to create two CosmosClient instances in my application, since I need to access data from two different cosmos accounts. But I find the dotnet SDK to very clunky on this point, especially since I cannot inject both instances into the DI services (both instances are of same type).
What would your approach be to this? Right now I'm in the process of writing some wrapper class around the CosmosClient/Container class to get around this. I find it odd that there is no DI helper methods that handles this, similar to how it works with HttpClientFactory. Is it such an uncommon thing to use multiple clients?
Also, is there any resource consideration around using multiple singleton clients in the app? I know you should only have one CosmosClient instance in your app, but that is only true if you're connecting to one account?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I need to create two CosmosClient instances in my application, since I need to access data from two different cosmos accounts. But I find the dotnet SDK to very clunky on this point, especially since I cannot inject both instances into the DI services (both instances are of same type).
What would your approach be to this? Right now I'm in the process of writing some wrapper class around the CosmosClient/Container class to get around this. I find it odd that there is no DI helper methods that handles this, similar to how it works with HttpClientFactory. Is it such an uncommon thing to use multiple clients?
Also, is there any resource consideration around using multiple singleton clients in the app? I know you should only have one CosmosClient instance in your app, but that is only true if you're connecting to one account?
Beta Was this translation helpful? Give feedback.
All reactions