Proper CloudTableClient instance lifecycle?

You need to create a new instance of CloudTableClient with each request. Instance members are not thread-safe, so you can't share a singleton.


I think in 2020 you should reuse.

https://azure.microsoft.com/en-us/blog/performance-tips-for-azure-documentdb-part-1-2/


I came across this question / answer wondering the same thing and whilst looking through the SDK's source code (for something else) I came across something useful:

When executing an operation, the SDK is using a HttpClientFactory, so a single static instance of HttpClient is being reused. Which is good, and corrects the Improper Instantiation antipattern, so the common reason to use a singleton is already sorted for us.

Relevant code can be found on github During Execution and the HttpClient factory is implemented via a static Lazy<T>

Notably the Storage SDK doesn't support Table anymore (instead the Cosmos SDK appears to provide it - I'm learning more), so this is likely a moot observation.