How to add Access Policies to Key Vault, when adding App Service? I need "Principal ID" of added App Service. #3747
-
How to add Access Policies to Key Vault, when adding App Service? I need "Principal ID" of added App Service. I'm trying to get a Principal ID. But I get error on deployment: {"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"InvalidTemplate","message":"Unable to process template language expressions for resource '/subscriptions/xxxxxxx-yyyyyy-xxxxxxxx/resourceGroups/my-resource-group-name/providers/Microsoft.KeyVault/vaults/my-key-vault-name/accessPolicies/add' at line '1' and column '2267'. 'The language expression property 'identity' doesn't exist, available properties are 'apiVersion, location, tags, kind, properties, deploymentResourceLineInfo, subscriptionId, resourceGroupName, scope, resourceId, referenceApiVersion, condition, isConditionTrue, isTemplateResource, isAction, provisioningOperation'.'"}]} My code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Adding either User assigned or System assigned managed identity to the Web site is an optional configuration. To use User assigned you pre-create the identity then assign it, to use System assigned you simply enable it. Since you are not providing that configuration item when you create your website that property is not available to read back. Syntax: identity: {
type: 'string'
userAssignedIdentities: {}
} The mimimum you need for system assigned is identity: {
type: 'SystemAssigned'
} Otherwise for user assigned or mixed identity: {
type: 'SystemAssigned, UserAssigned'
userAssignedIdentities: {
'${resourceId('Microsoft.ManagedIdentity/userAssignedIdentities/', 'myuaiStorageAccountOperator')}': {}
}
} here is another view, in this case I enable both system and user identities, using a lookup table from different identities in the variables section to enable/assign 1 or more user identities: Once you have that you should them be able to read the principalid back in order to assign to the access policy. |
Beta Was this translation helpful? Give feedback.
Adding either User assigned or System assigned managed identity to the Web site is an optional configuration.
To use User assigned you pre-create the identity then assign it, to use System assigned you simply enable it.
https://docs.microsoft.com/en-us/azure/templates/microsoft.web/staticsites?tabs=bicep#ManagedServiceIdentity
Since you are not providing that configuration item when you create your website that property is not available to read back.
Syntax:
The mimimum you need for system assigned is
Otherwise for user assigned or mixed