Last active
September 24, 2024 17:53
-
-
Save thepaulmacca/40c6916bebc1dee00e414615edef37d8 to your computer and use it in GitHub Desktop.
Bicep - Key Vault Secret User RBAC Role Assignment - App Service Identity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource keyVault 'Microsoft.KeyVault/vaults@2019-09-01' existing = { | |
name: keyVaultName | |
} | |
@description('This is the built-in Key Vault Secret User role. See https://docs.microsoft.com/azure/role-based-access-control/built-in-roles#key-vault-secrets-user') | |
resource keyVaultSecretUserRoleRoleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = { | |
scope: subscription() | |
name: '4633458b-17de-408a-b874-0445c86b69e6' | |
} | |
@description('Grant the app service identity with key vault secret user role permissions over the key vault. This allows reading secret contents') | |
resource keyVaultSecretUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2020-08-01-preview' = { | |
scope: keyVault | |
name: guid(resourceGroup().id, appService.id, keyVaultSecretUserRoleRoleDefinition.id) | |
properties: { | |
roleDefinitionId: keyVaultSecretUserRoleRoleDefinition.id | |
principalId: appService.identity.principalId | |
principalType: 'ServicePrincipal' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment