[FEATURE REQ] Make the process of using a CustomerProvidedKey with BlobClient more DI-friendly
See original GitHub issueLibrary or service name. Azure.Storage.Blobs
Is your feature request related to a problem? Please describe.
Currently, the process of setting up a BlobClient
instance to use a CustomerProvidedKey
in projects that leverage DI (e.g., and ASP.NET Core project) is very annoying.
You can inject BlobServiceClient
via DI, and obviously you can create BlobContainerClient
s and BlobClient
s using the injected BlobServiceClient
instance. That’s great for normal usage…but as soon as I need to create a BlobClient
that uses a CustomerProvidedKey
, it becomes frustrating, because:
CustomerProvidedKey
must be passed viaBlobClientOptions
- The only way to pass
BlobClientOptions
toBlobClient
is via its constructors, there’s no other way via the “normal”BlobServiceClient
->BlobContainerClient
->BlobClient
route. - To make things even more annoying, there’s nothing I can “get” from the injected
BlobServiceClient
and pass to theBlobClient
constructor to let me “inherit” the identity, URI, etc in that fashion.
So what you end up with is a situation where your DI-injected BlobServiceClient
becomes useless, and you have to inject all of the information needed to set up a brand new BlobClient
instance using IOptions<Foo>
(or something similar).
For my specific use-case, we generate new encryption keys for each new blob we upload, so I’ve basically ended up creating a BlobClient
factory and inject that via DI, but it would really be preferable if there were some way to just create the BlobClient
via BlobServiceClient
I’m already injecting for other reasons.
If there were an extra overload of BlobContainerClient.GetBlobClient()
that took a second parameter of type BlobClientOptions
(or perhaps simply CustomerProvidedKey
), that would be excellent.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (7 by maintainers)
Top GitHub Comments
@tg-msft, just want to double check, we are cool with:
BlobServiceClient.WithCustomerProvidedKey(CustomerProvidedKey customerProvidedKey)
BlobContainerClient.WithCustomerProvidedKey(CustomerProvidedKey customerProvidedKey)
BlobBaseClient.WithCustomerProvidedKey(CustomerProvidedKey customerProvidedKey)
We could also consider adding
WithEncryptionScope()
, since the idea is essentially the same.Ok, I will work on this this week.