Mostly just a link to this article containing best practices.

There’s some useful extension methods available from Microsoft.Extensions.Azure to make for easier dependency injection of the various Azure services.

public void ConfigureServices(IServiceCollection services)
{
	services.AddAzureClients(builder =>
	{
		// Add a KeyVault client
		builder.AddSecretClient(keyVaultUrl);

		// Add a storage account client
		builder.AddBlobServiceClient(storageUrl);

		// Use the environment credential by default
		builder.UseCredential(new EnvironmentCredential());
	});

	services.AddControllers();
}

There’s also some good examples available here.


2 Comments

Azure Table Storage Depeendency Injection – bitScry · 9th March 2021 at 10:40 am

[…] methods for adding a BlobServiceClient are provided by Microsoft as previously mentioned, however there’s no equivlent for adding access for Table (or Cosmos DB) […]

Azure Table Storage Dependency Injection – bitScry · 9th March 2021 at 10:47 am

[…] methods for adding a BlobServiceClient are provided by Microsoft as previously mentioned, however there’s no equivlent for adding access for Table (or Cosmos DB) […]

Leave a Reply

Your email address will not be published. Required fields are marked *