Missing feature: Credential support for AzureBlobStorageImageProvider and AzureBlobStorageCache #360
Unanswered
marklagendijk
asked this question in
Show and tell
Replies: 1 comment 4 replies
-
|
A similar but different option/pattern I've seen used in various places would be to extend public partial class AzureBlobStorageCacheOptions{
+ public Func<AzureBlobStorageCacheOptions, IServiceProvider, BlobServiceClient>? ClientProvider { get; set; } = null;
}public partial class AzureBlobStorageCache {
public AzureBlobStorageCache(IOptions<AzureBlobStorageCacheOptions> cacheOptions, IServiceProvider serviceProvider)
{
var options = cacheOptions.Value;
if (options .ClientProvider == null)
{
this.container = new BlobContainerClient(options.ConnectionString, options.ContainerName);
}
else
{
this.container = options .ClientProvider(options, serviceProvider);
}
this.cacheFolder = string.IsNullOrEmpty(options.CacheFolder)
? string.Empty
: options.CacheFolder.Trim().Trim('/') + '/';
}
}This makes it possible to use separate It would also make sense to add the same pattern in for the AWs provider too |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently both the
AzureBlobStorageImageProviderand theAzureBlobStorageCacherequire aConnectionStringto function.Authenticating with a
ConnectionStringis only one of the many possible ways to authenticate with Azure Blob Storage.In our software we use the DefaultAzureCredential. This automatically recognizes which authentication method is supplied on the system and uses that.
On our production systems we use a Managed Identity with roles based authentication to get access to all the resources it needs.
I think the easiest way of allowing all authentication types would be to inject the
BlobServiceClientso that the setup of theBlobServiceClientbecomes the concern of the user.In this example I added an option
UseBlobServiceClientFromDiand inject theBlobServiceClientwhen that option is used:In our sofware we actually support both the
ConnectionStringandAccount Name + DefaultAzureCredentialapproaches, so that we can easily use Azurite for local development, by using theUseDevelopmentStorage=trueconnection string:Beta Was this translation helpful? Give feedback.
All reactions