Search code examples
azure-blob-storageazure-storage

Should I save BlobServiceClient & BlobContainerClient for the life of my app?


Are BlobServiceClient & BlobContainerClient lightweight like DbContext so it's fine to instantiate them anytime needed?

Or do they take appreciable time to construct and therefore I should create them when my app starts and keep those objects for the life of the app (figure a month max because Azure app service moves a web app monthly to apply Windows updates to each system)?


Solution

  • With the latest AzureSDKs it is recommended to instantiate BlobServiceClient as singleton. https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/