Deploying storage account with CMK #3485
-
|
Hello, I wanted to deploy a storage account, that has a CMK (Customer managed key) encryption enabled. I found out that the API prohibits that from happening at deployment time. I found an ARM template that achieves that, using nested resources. So basically it deploys the storage account, then key vault with proper access policy from storage accounts MI and then updates the storage account with CMK encryption, all in one template. But i couldn't find any way to implement that in Bicep. DependsOn doesnt accept the fact that two resources have the same name, and parent doesn't accept the fact that's it not actually a child resource. I also found out that i can do it through powershell, but didnt find a way to include that in bicep (as i understand that's not the point of using bicep in the first place). So, after this a little too long introduction, my main goal is to have a single deployment file/module for a storage account that encrypts it using CMK. Could you guys point me in the correct direction/bicep feature to achieve something like this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
ARM templates are subject to the same limitation around not being able to deploy the same resource twice in a single template. The example you shared from StackOverflow uses a nested deployment to work around this fact. You should be able to achieve the same in Bicep with the following by using modules. Here I've decompiled and cleaned up the StackOverflow sample:
|
Beta Was this translation helpful? Give feedback.
-
|
Thank you both for all your help :) |
Beta Was this translation helpful? Give feedback.
ARM templates are subject to the same limitation around not being able to deploy the same resource twice in a single template. The example you shared from StackOverflow uses a nested deployment to work around this fact. You should be able to achieve the same in Bicep with the following by using modules.
Here I've decompiled and cleaned up the StackOverflow sample: