Issue with keyvault access policy resource
Bicep version Bicep CLI version 0.2.59 (5b0314c03c)
Describe the bug
I was trying to create a module for keyvault policies. The keyvaultaccess resource is not allowing to specify the pattern "keyvaultname/add" in the name parameter of the resource. But this is the only way we can add an access policy through the ARM template. Bicep throws a compilation error.

Please check the screenshot below.
To Reproduce
Steps to reproduce the behavior:

Additional context
If I modify the ARM template it works. See the screenshot here.

I have done a workaround like this and I am good for now. But please look into the issue.

I know this was closed, but it feels like this should be addressed still. While the work around is working it isn't consistent even within Key Vault child resources. I like the idea of having the name suggestions but not enforcing it to something so strict.

I know this was closed, but it feels like this should be addressed still. While the work around is working it isn't consistent even within Key Vault child resources. I like the idea of having the name suggestions but not enforcing it to something so strict.
Long-term, we will have the nested resource syntax as well as the parent property syntax to improve deployment of child resources - at which point, this issue and the issues under #657 (similar root case) will be sorted. Below are some previews of both options, and note that neither option requires any string formatting with '/' characters:
Nested resource syntax (#1516):
resource keyvault 'Microsoft.KeyVault/vaults@2020-04-01-preview' = {
...
resource accesspolicy 'accessPolicies' = {
name: 'add'
...
}
}
Parent property syntax (#1800):
resource keyvault 'Microsoft.KeyVault/vaults@2020-04-01-preview' = {
...
}
resource accesspolicy 'Microsoft.KeyVault/vaults/accessPolicies@2020-04-01-preview' = {
parent: keyvault
name: 'add'
...
}
Awesome, thanks for the update
Parent property syntax (#1800):
resource keyvault 'Microsoft.KeyVault/vaults@2020-04-01-preview' = { ... } resource accesspolicy 'Microsoft.KeyVault/vaults/accessPolicies@2020-04-01-preview' = { parent: keyvault name: 'add' ... }
How can we do this in een loop?
I have the following:
resource kv 'Microsoft.KeyVault/vaults@2021-10-01' = {
...
}
resource accessPolicies 'Microsoft.KeyVault/vaults/accessPolicies@2021-10-01' = [for accessPolicy in accessPoliciesObject.accessPolicies: {
name: 'add'
parent: kv
properties: {
accessPolicies: [
{
tenantId: tenantId
objectId: accessPolicy.objectId
permissions: {
keys: accessPolicy.keysPermissions
secrets: accessPolicy.secretsPermissions
certificates: accessPolicy.certificatesPermissions
}
}
]
}
}]
@LockTar - given this issue is a bit stale, can you ask this question in Bicep Discussions?
cc @brwilkinson as FYI
@LockTar - given this issue is a bit stale, can you ask this question in Bicep Discussions?
I created discussion #6203