In .net Core 3 project, i have to use the CloudStorageAccount class for interacting with the Blob containers.
Here is sample code :-
public class CloudStorageManager : ICloudStorageManager
{
private readonly CloudStorageAccount cloudStorageAccount;
public CloudStorageManager(TIMConfiguration configuration)
{
if (!CloudStorageAccount.TryParse(configuration.AzureAdConfigurationSection.StorageConnectionString, out cloudStorageAccount))
throw new FormatException("bad cloud connection string");
} }
I have defined various methods inside this class. Inside the startup.cs class, the registration is added like this :-
services.AddTransient<ICloudStorageManager, CloudStorageManager>();
I would like to know how can i make the CloudStorageManager class constructor better by removing the logic from it. Shall i replace it with the static constructor, since i need this initialization only once.
Secondly, can i use the Singleton scope for the registration because it will be same for all the clients.
Please advise on the resolution.