My issue is the following:
We have an ARM template that deploys our function app. In the template we add an access policy for the function app to our keyvault in the following way.
{
"name": "[concat(parameters('keyVaultName'), '/add')]",
"type": "Microsoft.KeyVault/vaults/accessPolicies",
"apiVersion": "2019-09-01",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('skuAPIHostingPlan'))]",
"[resourceId('Microsoft.Web/sites', variables('functionAppName'))]"
],
"properties": {
"accessPolicies": [
{
"tenantId": "[parameters('tenantId')]",
"objectId": "[reference(variables('functionAppResourceId'), '2021-01-15', 'Full').identity.principalId]",
"permissions": {
"secrets": "[parameters('functionSecretsPermissions')]"
}
}
]
}
}
I would like to have a dependsOn statement in another resource in the template referencing the newly created access policy but don't quite know how to construct it. I guess I can't use the resourceId function (as I do in the access policy resource) as the access policy was not created with a specific resourcename (which I would need to pass on to the resourceId function).
Any ideas on how I can reference my access policy from the dependsOn section of another resource in the template ?