title: ARM template dependsOn on a keyvault access policy
body: <p>My issue is the following:</p>
  <p>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.</p>
  <pre><code>   {
       &quot;name&quot;: &quot;[concat(parameters('keyVaultName'), '/add')]&quot;,
       &quot;type&quot;: &quot;Microsoft.KeyVault/vaults/accessPolicies&quot;,
       &quot;apiVersion&quot;: &quot;2019-09-01&quot;,
       &quot;dependsOn&quot;: [
         &quot;[resourceId('Microsoft.Web/serverfarms', variables('skuAPIHostingPlan'))]&quot;,
         &quot;[resourceId('Microsoft.Web/sites', variables('functionAppName'))]&quot;
       ],
       &quot;properties&quot;: {
         &quot;accessPolicies&quot;: [
           {
             &quot;tenantId&quot;: &quot;[parameters('tenantId')]&quot;,
             &quot;objectId&quot;: &quot;[reference(variables('functionAppResourceId'), '2021-01-15', 'Full').identity.principalId]&quot;,
             &quot;permissions&quot;: {
               &quot;secrets&quot;: &quot;[parameters('functionSecretsPermissions')]&quot;
             }
           }
         ]
       }
     }
  </code></pre>
  <p>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).</p>
  <p>Any ideas on how I can reference my access policy from the dependsOn section of another resource in the template ?</p>