• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How do i create an access policy for my azure function with bicep?

Resolved: How do i create an access policy for my azure function with bicep?

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a resource defined in my bicep file like this below, these are two of the resources in my file, i deploy an azure function with the test_resource below, this works fine.
resource test_resource 'Microsoft.Web/sites@2021-03-01' = {
  name: resourceName
  location: location
  kind: 'functionapp'
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    httpsOnly: true
    serverFarmId: appServicePlan_ResourceId
  }
}
and i am attempting to create an access policy as shown below, however i get an error regard the objectId, is there a way to configure the access policy for the above resource, perharps i am passing the wrong id in
"Invalid value found at accessPolicies[0].ObjectId: 
but i am passing the test_resource.id as shown in the keyvault_access_policy resource definition.
resource devops_keyvault 'Microsoft.KeyVault/vaults@2021-10-01' existing = {
  name: keyVaultName
}

resource keyvault_access_policy 'Microsoft.KeyVault/vaults/accessPolicies@2021-10-01' = {
  name: 'add'
  parent: devops_keyvault
  properties: {
    accessPolicies: [
      {
        objectId: test_resource.id 
        permissions: {
          'keys': []
          'secrets': [
            'list'
            'get'
          ]
          'certificates': [
            'list'
            'get'
          ]
        }
        tenantId: subscription().tenantId
      }
    ]
  }
}

Answer:

Looking at the documentation:

objectId: The object ID of a user, service principal or security group in the Azure Active Directory tenant for the vault. The object ID must be unique for the list of access policies.


In your case it should be the the principal ID of the managed identity:
objectId: test_resource.identity.principalId

If you have better answer, please add a comment about this, thank you!

azure azure-bicep azure-functions azure-managed-identity
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: itertools: cycle through several lists N times via iteration

24/03/2023

Resolved: Convert function is not working with {fn } in SQL Server

24/03/2023

Resolved: Why reference in pointer array doesn’t have data?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.