-
Notifications
You must be signed in to change notification settings - Fork 418
Expand file tree
/
Copy pathdeploy_managed_identity.bicep
More file actions
47 lines (39 loc) · 1.33 KB
/
deploy_managed_identity.bicep
File metadata and controls
47 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// ========== Managed Identity ========== //
targetScope = 'resourceGroup'
@minLength(3)
@maxLength(15)
@description('Solution Name')
param solutionName string
@description('Solution Location')
param solutionLocation string
@description('Name')
param miName string
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: miName
location: solutionLocation
tags: {
app: solutionName
location: solutionLocation
}
}
@description('This is the built-in owner role. See https://docs.microsoft.com/azure/role-based-access-control/built-in-roles#owner')
resource ownerRoleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = {
scope: resourceGroup()
name: '8e3af657-a8ff-443c-a75c-2fe8c4bcb635'
}
resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(resourceGroup().id, managedIdentity.id, ownerRoleDefinition.id)
properties: {
principalId: managedIdentity.properties.principalId
roleDefinitionId: ownerRoleDefinition.id
principalType: 'ServicePrincipal'
}
}
output managedIdentityOutput object = {
id: managedIdentity.id
objectId: managedIdentity.properties.principalId
resourceId: managedIdentity.id
location: managedIdentity.location
name: miName
}
output managedIdentityId string = managedIdentity.id