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
-
Currently both the
AzureBlobStorageImageProvider
and theAzureBlobStorageCache
require aConnectionString
to function.Authenticating with a
ConnectionString
is 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
BlobServiceClient
so that the setup of theBlobServiceClient
becomes the concern of the user.In this example I added an option
UseBlobServiceClientFromDi
and inject theBlobServiceClient
when that option is used:In our sofware we actually support both the
ConnectionString
andAccount Name + DefaultAzureCredential
approaches, so that we can easily use Azurite for local development, by using theUseDevelopmentStorage=true
connection string:Beta Was this translation helpful? Give feedback.
All reactions