Skip to content

Instantly share code, notes, and snippets.

@waldekmastykarz
Last active August 9, 2024 15:37
Show Gist options
  • Save waldekmastykarz/19285788080b9f794d0d275f5df0b1b4 to your computer and use it in GitHub Desktop.
Save waldekmastykarz/19285788080b9f794d0d275f5df0b1b4 to your computer and use it in GitHub Desktop.
Create MSI with app roles assigned
extension microsoftGraph
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
location: resourceGroup().location
name: 'my-connector'
}
resource graphSp 'Microsoft.Graph/[email protected]' existing = {
appId: '00000003-0000-0000-c000-000000000000'
}
var graphAppRoles = graphSp.appRoles
resource externalConnectionReadWriteOwnedByAssignment 'Microsoft.Graph/[email protected]' = {
principalId: identity.properties.principalId
resourceId: graphSp.id
appRoleId: filter(graphAppRoles, r => r.value == 'ExternalConnection.ReadWrite.OwnedBy')[0].id
}
resource externalItemReadWriteOwnedByAssignment 'Microsoft.Graph/[email protected]' = {
principalId: identity.properties.principalId
resourceId: graphSp.id
appRoleId: filter(graphAppRoles, r => r.value == 'ExternalItem.ReadWrite.OwnedBy')[0].id
}
output identityId string = identity.properties.clientId
output spId string = identity.properties.principalId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment