An API that connects multiple Microsoft services, enabling data access and automation across platforms
Assign with powershell:
$managedIdentity = Get-MgServicePrincipal -ServicePrincipalId '<object id>'
$graphSPN = Get-MgServicePrincipal -Filter "AppId eq '00000003-0000-0000-c000-000000000000'"
#Add the needed perm
$permission = "Group.Read.All"
#find app role and type
$appRole = $graphSPN.AppRoles |
Where-Object Value -eq $permission |
Where-Object AllowedMemberTypes -contains "Application"
$bodyParam = @{
PrincipalId = $managedIdentity.Id
ResourceId = $graphSPN.Id
AppRoleId = $appRole.Id
}
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $managedIdentity.Id -BodyParameter $bodyParam