-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AVM Question/Feedback]: Accessing Storage Account Access Key #1780
Comments
I concur with this issue. This is an acute problem I am facing as I try to deploy the AVM avm/res/web/site for a FunctionApp. That module does not deploy the mandatory WEBSITE_CONTENTAZUREFILECONNECTIONSTRING appSetting (see https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#website_contentazurefileconnectionstring) and that requires the full connection string too. I will create a separate issue for that template though as I think that template could more be fixed to include deployment of this appSetting without necessarily surfacing the keys in this storage template. |
Hi, thanks for opening this issue. Thats actually quite a tricky one, the only way around this I am aware of, would be to store the access key in a keyvault, if a certain set of parameters (e.g. kv-name, secret-name, etc) are provided. But maybe there are other ways, too. @eriqua @AlexanderSehr @ChrisSidebotham do you have any ideas or references how other modules did it? |
Thank you for your reply @fblix. Ideally, as part of infrastructure provisioning, the access key should be stored in the key vault as a secret, with its value seeded. However, the question remains: how to access the access key for the storage account when using the storage account module? |
That was what my comment was supposed to be about. Currently I do not know of a way to securely achieve this, but an idea could be to extend the storage account module to accept a target keyvault as a parameter in which the module would store the access key. |
This is not only a challenge for storage accounts but also the cognitive services (OpenAI, Speech, Search etc.) produce secrets that need to be stored safely in a key vault. the AVM document db module has a solution that i actually like very much: https://github.com/Azure/bicep-registry-modules/blob/main/avm/res/document-db/database-account/main.bicep It takes a key vault object . If only the name of the key vault is submitted, all other variables are calculated and all secrets are stored safely in the key vault. If additional details are added, the names in the key vault can be controlled. This is done by using a local key vault module within the document db module. I think it would be a good idea to have a uniform way to get secrets into key vault from all modules that produce secrets. Currently, we are working on a deployment that has both storage accounts, several cognitive bits and document db, and document db is the only one that plays nicely with key vault. We would be happy to helt with implementing a uniform solution in the modules where we currently need to use our own modules because of this secret-to-key-vault issue, so our deployment can be AVM only :-) What is the teams view on the solution done in document db and are there any discussions on how to manage the secrets with a common approach? |
TL;DR: I would take a keyVault as an option, and provide switches to write either the key itself or the connection string to that key value and whether you do one or both key. I do see your idea for using a keyvault but that may violate the AVM principles of creating an unnecessary dependancy (even if optional) for a very common thing (i.e. a storage account). It seems to me that the resource provider already provides the analogous means called "listKey()" even if it isn't included in the output specifically. But perhaps the whole point is that the output is stored permanently in the deployment object and thus that would be a very insecure manner. A key vault would be better than nothing, for sure, but it may not always work (as in my case of a function app, there are scenario's where a key vault reference seem to not do well with the basic connection strings). |
|
Exactly, you're affirming what I said. But this means that AVM, practically speaking, is inferior because we do not have such a means to use. It isn't AVM's fault, but rather a Bicep's language limitation. My solution for my scenario was to not use the AVM module for storage accounts, instead using a resource declaration. That is not what I think the intended vision is for AVM, so if a solution could be figured out here that would be great. |
But using the resource declaration makes it hard to do looping in subscription deployments. That is kind of the great thing about the AVM modules. You are not allowed to add a scope to resource deployments. |
Hey together,
Sadly, while working, this is of course a workaround which is annoying to say the least. There are 2 things that would help with this once implemented in Bicep
|
In my opinion the modules should make life easier. Having to do part of the deployment in one file and then handle the rest in another file and having to add extra "existing" resource code in the second file is far from ideal for the deployment builder. The module should take care of that. The implementation made in Document DB does make a larger module, but it seems fitting for resources that emit secrets which We have been waiting for a solution for this scenario for a long time. Is anything planned in the upcoming sprints to fix it? Unfortunately I have not been able to follow the discussions about this very hot topic. Does anyone have a link to the discussions or does anyone know, why the beautiful implementation in document db was allowed in the first place? Or is it planned to get trimmed away again? |
Hey @Agazoth, That being said, the KeyVault-Secerets solution of Document DB is a also valid workaround. It's still a workaround (and comes with it's own challenges) but the module owner can certainly add it. Once the desired Bicep features are released, it may render it redundant, but like I wrote in the original comment, give a missing timeline it's not really worth waiting for. Regarding your question 'why it was allowed' - it's simple, it was allowed because it does not violate any specs and the module owner @bryansan-msft contributed it. 🚀 That's it. I would be very suprised if there'd be any plan to remove it again. Long story short, if @fblix is up for it, he can certainly add the implementation to the storage account module, as would be the owner of the Cognitive Services module you mentioned. It's an optional feature afterall, and does not open any new branching paths regarding how the module works (which would add to the module's complexity). PS: Personally, when building solutions I prefer going with 'existing' resources simply for the fact that they provide all the features I want (i.e., aside from functions, also all kinds of the latest properties), and simply build the solutions with the structural constraints in mind. If working with Bicep taught me anything, then it's that I'll end up with multiple files sooner or later anyways 😄 (given existing references, scope changes, grouping, etc. all requiring just that). But everyone has their own preferences. |
Until there is a way to manage a secure output in bicep, there isn't a way to achieve this request securely entirely withing the scope of the storage account resource module in a way that would meet the WAF framework security model. This is probably a candidate to be closed for now and look to (re-)open when future functionality is available. |
Or tie it to #1934 |
Agreed @Agazoth, |
Check for previous/existing GitHub issues
Description
We've utilized the AVM approach for deploying several storage accounts, as detailed in the repository: https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/storage/storage-account
What's the recommended method for accessing the access key of these storage accounts? We've observed that the outputs don't include any parameters for this purpose.
This concern arises particularly when deploying multiple resources, such as storage accounts and Azure Functions, where the Azure Functions' configuration settings needs the connection string containing the access key of the storage account. Currently, we're blocked from achieving this.
Any guidance on this matter would be greatly appreciated.
The text was updated successfully, but these errors were encountered: