Skip to main content

Assign Permissions to the App Service

The EntraID SCIM microservice requires specific permissions to interact with Microsoft Graph API and Azure resources. You can implement permissions using two approaches: tenant-wide application permissions for simplicity, or custom Azure roles with least privilege for enhanced security. Choose the approach that best aligns with your organization's security policies and compliance requirements.

Permission Assignment Approaches

Approach 1: Tenant-Wide Application Permissions (Traditional)

This approach provides broad access across your entire EntraID tenant with simple management through single permission assignments. Ideal for:

  • Standard deployments where broad access is acceptable
  • Organizations without strict least-privilege requirements
  • Development and testing environments requiring quick setup
  • Simplified permission management with one-time admin consent for all permissions
  • Faster initial configuration with minimal administrative overhead

This approach offers granular control with permissions scoped to specific resources, providing enhanced security with minimal blast radius if credentials are compromised. Best suited for:

  • Enterprise environments with strict security policies
  • Compliance requirements mandating minimal access (meets most regulatory frameworks)
  • Multi-tenant or shared environments requiring precise access control
  • Organizations following Zero Trust principles
  • Flexible scoping where permissions can be limited to specific groups, OUs, or resources
  • Advanced security needs requiring detailed audit trails and permission lifecycle management

Implementation Guide

Approach 1: Tenant-Wide Application Permissions

This approach grants broad permissions across your entire EntraID tenant. The managed identity will have access to all resources of the specified types.

Required Microsoft Graph API Permissions

Core Permissions (Required for all deployments):

$CorePermissions = @(
"Directory.Read.All",
"Organization.Read.All",
"User.Read.All",
"User.ReadWrite.All",
"Group.Read.All",
"Group.ReadWrite.All",
"GroupMember.Read.All",
"GroupMember.ReadWrite.All",
"Reports.Read.All",
"AuditLog.Read.All"
)

Extended Permissions (Based on features needed):

$ExtendedPermissions = @(
# Application Management
"Application.Read.All",
"Application.ReadWrite.All",
"AppRoleAssignment.ReadWrite.All",

# Role Management
"RoleManagement.Read.All",
"RoleManagement.ReadWrite.Directory",

# Security & Conditional Access
"Policy.Read.All",
"Policy.ReadWrite.ConditionalAccess",
"CustomSecAttributeDefinition.ReadWrite.All",
"CustomSecAttributeAssignment.ReadWrite.All",

# Authentication Methods
"UserAuthenticationMethod.ReadWrite.All",

# Domain Management
"Domain.Read.All"
)

PowerShell Script for Tenant-Wide Permissions

# Configuration
$webApp = "<Your-App-Service-Name>"
$subscriptionName = "<Your-Subscription-Name>"
$tenantID = "<Your-Tenant-ID>"

# Set tenant and subscription context
az login --tenant $tenantID
az account set -s $subscriptionName

# Get managed identity details
$principalId = $(az resource list -n $webApp --query [*].identity.principalId --out tsv)
$graphResourceId = $(az ad sp list --display-name "Microsoft Graph" --query [0].id --out tsv)

# Define permissions based on your requirements
$RequiredPermissions = @(
"Directory.Read.All",
"Organization.Read.All",
"User.Read.All",
"User.ReadWrite.All",
"Group.Read.All",
"Group.ReadWrite.All",
"GroupMember.Read.All",
"Reports.Read.All",
"AuditLog.Read.All",
"Application.Read.All",
"Policy.Read.All",
"RoleManagement.Read.All",
"Domain.Read.All"
)

# Apply permissions
$uri = "https://graph.microsoft.com/v1.0/servicePrincipals/$principalId/appRoleAssignments"

$RequiredPermissions | ForEach-Object {
$appRoleId = $(az ad sp list --display-name "Microsoft Graph" --query "[0].appRoles[?value=='$($_)' && contains(allowedMemberTypes, 'Application')].id" --output tsv)
$body = "{'principalId':'$principalId','resourceId':'$graphResourceId','appRoleId':'$appRoleId'}"

Write-Host "Assigning permission: $_"
az rest --method post --uri $uri --body $body --headers "Content-Type=application/json"
}

Write-Host "Tenant-wide permissions assigned successfully"

Verify Tenant-Wide Permissions

Method 1: PowerShell Verification

# Verify assigned permissions
$principalId = "<Your-Managed-Identity-Principal-ID>"
$uri = "https://graph.microsoft.com/v1.0/servicePrincipals/$principalId/appRoleAssignments"

$assignments = az rest --method get --uri $uri | ConvertFrom-Json
$assignments.value | Select-Object -Property resourceDisplayName, @{Name="Permission";Expression={$_.appRoleId}}

Method 2: Azure Portal Verification

You can also verify the permissions through the Azure portal:

  1. Navigate to Azure Active DirectoryEnterprise Applications
  2. Filter by Application type: Select Managed Identities
  3. Find your App Service managed identity in the list
  4. Click on the managed identity name to open its details
  5. Go to Permissions in the left navigation menu
  6. Review the Microsoft Graph permissions that have been assigned

You should see all the permissions you assigned in the script with Admin consent granted, as shown below:

Approach 2: Entra ID (Azure AD) Custom Role with Least Privilege

This approach involves creating custom directory roles in Entra ID (formerly Azure AD) with the least required permissions and assigning them to your managed identity at the directory level. These roles enable granular access control over identity-related objects such as users, groups, applications, service principals, and licenses. They use the microsoft.directory/* permission set and are primarily intended for managing directory resources through the Microsoft Graph API.

Step 1: Create Entra ID (Azure AD) Custom Role with Limited Permissions

Create a custom directory role that only has permissions for User object read and update operations:

Connect-MgGraph -Scopes "RoleManagement.ReadWrite.Directory"

# Basic role information
$displayName = "EID SCIM Connector - Limited User Management"
$description = "Custom directory role for EmpowerID SCIM connector with limited user read and update permissions"
$templateId = (New-Guid).Guid

# Set of permissions to grant
$allowedResourceAction = @(
"microsoft.directory/users/appRoleAssignments/read",
"microsoft.directory/users/assignLicense",
"microsoft.directory/users/basic/update",
"microsoft.directory/users/contactInfo/update",
"microsoft.directory/users/directReports/read",
"microsoft.directory/users/extensionProperties/update",
"microsoft.directory/users/identities/read",
"microsoft.directory/users/jobInfo/update",
"microsoft.directory/users/licenseDetails/read",
"microsoft.directory/users/manager/read",
"microsoft.directory/users/manager/update",
"microsoft.directory/users/memberOf/read",
"microsoft.directory/users/passwordPolicies/update",
"microsoft.directory/users/scopedRoleMemberOf/read",
"microsoft.directory/users/standard/read",
"microsoft.directory/users/usageLocation/update"
)
$rolePermission = @{'allowedResourceActions'= $allowedResourceAction}
$rolePermissions = $rolePermission

# Create new custom admin role
$customRole = New-MgRoleManagementDirectoryRoleDefinition -Description $description `
-DisplayName $displayName -RolePermissions $rolePermissions -TemplateId $templateId -IsEnabled

Step 2: Assign Custom Directory Role to Managed Identity at Directory Scope

Assign the newly created custom role to your managed identity:

# Assign the custom role to the managed identity at directory scope
$managedIdentityPrincipalId = "<Your-User-Assigned-Managed-Identity-Principal-ID>"
$directoryScope = "/"

$roleAssignment = New-MgRoleManagementDirectoryRoleAssignment -DirectoryScopeId $directoryScope -PrincipalId $managedIdentityPrincipalId -RoleDefinitionId $customRole.Id

Step 3: Verify Custom Directory Role Assignment

Method 1: PowerShell Verification

# Verify the assignment
$verifyUri = "https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments?`$filter=principalId eq '$managedIdentityPrincipalId'"
$assignments = az rest --method get --uri $verifyUri | ConvertFrom-Json

Write-Host "✓ Role assignment verification:" -ForegroundColor Green
$assignments.value | ForEach-Object {
Write-Host " - Role Definition ID: $($_.roleDefinitionId)" -ForegroundColor Cyan
Write-Host " - Directory Scope: $($_.directoryScopeId)" -ForegroundColor Cyan
Write-Host " - Principal ID: $($_.principalId)" -ForegroundColor Cyan
}

Method 2: Azure Portal Verification

You can also verify the custom directory role assignment through the Azure portal:

  1. Navigate to Azure Active DirectoryRoles and administrators
  2. Search for your custom role: "EID SCIM Connector - Limited User Management"
  3. Click on the custom role name to open its details
  4. Go to Assignments in the left navigation menu
  5. Review the role assignments to confirm your managed identity is listed

You should see your managed identity assigned to the custom directory role as shown below:

Create Azure RBAC Custom Role for Azure Resource Management

If you're managing Azure roles and management groups within EmpowerID, you’ll need to create an Azure RBAC custom role in addition to adding the necessary permissions in the script above. This custom role should include the required permissions, as outlined in the procedure below. Azure RBAC custom roles are used to govern access to Azure resources such as virtual machines, storage accounts, databases, and networking services. They are defined using Microsoft.* action sets and can be assigned at various scopes, including subscriptions, resource groups, or specific resources.

  1. In Azure, navigate to the target subscription and select Access control (IAM) from the Azure navbar.

  2. On the Access Control (IAM) page, click Add and select Add custom role.

  3. Under Basics, enter a Custom role name.

  4. Select the Permissions tab and click Add permissions.

  5. Search for Microsoft.ManagedIdentity and click the Microsoft Managed Identity tile.

  6. For Actions, under Microsoft.ManagedIdentity/userAssignedIdentities, select the following:

    • Read : Get User Assigned Identity
    • Write : Create/Update User Assigned Identity
    • Delete : Delete User Assigned Identity
  7. Click Add.

  8. Back on the Create a custom role page, click Add permissions again and then search for Microsoft.Authorization.

  9. Click the Microsoft Authorization tile and then add the below permissions:

    • Microsoft.Authorization/roleAssignments

      • Read : Get role assignment

      • Write : Create role assignment

      • Delete : Delete role assignment

    • Microsoft.Authorization/roleDefinitions

      • Read : Get role definition

      • Write : Create or update custom role definition

      • Delete : Delete custom role definition

  10. Click Add.

  11. Back on the Create a custom role page, click Add permissions again and then search for Microsoft.Authorization.

  12. Click the Microsoft Management tile and select Read : List Groups under Microsoft.Management/managementGroups.

  13. Click Add.

  14. Back on the Create a custom role page, click Add permissions again, and then search for Microsoft.Resources.

  15. Click the Microsoft Resources tile and then select the following permissions:

    • Microsoft.Resources/subscriptions/resourcegroups

      • Read : Get Resource Group
    • Microsoft.Resources/subscriptions/resources

      • Read : Get Subscription Resources
    • Microsoft.Resources/tenant

      • Read : Get Tenants
  16. Click Add.

  17. Back on the Create a custom role page, select the Assignable scopes tab and verify the scope.

  18. Click Review + Create.

  19. Review the permissions and then click Create.

  20. Click OK to close the "created custom role" message.

Now that you have created the custom role with the needed permissions, you need to assign the EntraID SCIM microservice to the role. 21. On the Access control (IAM) page, click Add > Add role assignment.
22. In the Add role assignment pane that appears, enter the following:

  • Role – Select the custom role you just created
  • Assign access to – App Service
  • Subscription – Target subscription
  • Select – The SCIM app service you created earlier.
  1. Click Save to add the role assignment.
  2. On the Access control (IAM) page, select the Role assignments tab. You should see the SCIM app service you created assigned to the custom role.

Troubleshooting Permission Issues

Common Issues and Solutions:

Issue: "Insufficient privileges to complete the operation"

  • Solution: Verify the specific permission required and ensure it's assigned
  • Check: Confirm admin consent has been granted

Issue: "The user or administrator has not consented to use the application"

  • Solution: Grant admin consent for the application permissions
  • PowerShell: Grant-AdminConsent -ApplicationId <app-id>

Issue: Custom role permissions not taking effect

  • Solution: Allow up to 15 minutes for role assignments to propagate
  • Check: Verify the role is assigned at the correct scope level

Appendix: Microsoft Graph API Permissions Reference

This appendix provides a comprehensive list of Microsoft Graph API Application Permissions required for each endpoint used in the EntraID SCIM Connector. These permissions represent the traditional tenant-wide approach, which grants broad access across all resources in your Azure tenant.

The permissions listed in the following tables represent traditional application-level permissions, but each can be replaced with an appropriate custom role definition when implementing the least-privilege approach.

User & Group Management

Endpoints related to user and group administration.

User Management

Operation DescriptionLeast Privileged Permissions
Create UserUser.ReadWrite.All
Update/Delete UserUser.ReadWrite.All
Get User by IDUser.Read.All
Get All UsersUser.Read.All
Get All Deleted UsersDirectory.Read.All
Get User Sign-In ActivityAuditLog.Read.All
Get Sign-Ins LogAuditLog.Read.All
Reset User PasswordUserAuthenticationMethod.ReadWrite.All
Revoke Sign-In SessionsUser.ReadWrite.All

Group Management

Operation DescriptionLeast Privileged Permissions
Create GroupGroup.ReadWrite.All
Update/Delete GroupGroup.ReadWrite.All
Get Group by IDGroup.Read.All
Get All GroupsGroup.Read.All
Get All Deleted GroupsDirectory.Read.All
Get Group MembersGroup.Read.All
Create Teams from GroupGroup.ReadWrite.All, Team.ReadWrite.All

Application & Service Principal Management

Endpoints for managing Applications and Service Principals.

Application Management

Operation DescriptionLeast Privileged Permissions
Create an ApplicationApplication.ReadWrite.All
Delete or Update an ApplicationApplication.ReadWrite.All
Get Application by IDApplication.Read.All
Get All ApplicationsApplication.Read.All
Get Application TemplatesApplication.Read.All
Add Certificate to ApplicationApplication.ReadWrite.All
Add Password to ApplicationApplication.ReadWrite.All
Remove Certificate from ApplicationApplication.ReadWrite.All
Remove Password from ApplicationApplication.ReadWrite.All

Service Principal Management

Operation DescriptionLeast Privileged Permissions
Create Service PrincipalApplication.ReadWrite.All
Delete or Update Service PrincipalApplication.ReadWrite.All
Get Service Principal by IDApplication.Read.All
Get All Service PrincipalsApplication.Read.All
Manage App Role AssignmentsAppRoleAssignment.ReadWrite.All

Role & Permissions Management

Endpoints related to role assignments and directory role management.

Operation DescriptionLeast Privileged Permissions
Create/Delete Directory Role AssignmentRoleManagement.ReadWrite.Directory
Create/Delete Unified Role AssignmentRoleManagement.ReadWrite.Directory
Create Role DefinitionRoleManagement.ReadWrite.Directory
Assign Role to User or GroupRoleManagement.ReadWrite.Directory
Get Role AssignmentsRoleManagement.Read.All
Get Role DefinitionsRoleManagement.Read.All

Security & Conditional Access

Endpoints related to Conditional Access Policies and Security Attributes.

Conditional Access

Operation DescriptionLeast Privileged Permissions
Create Conditional Access PolicyPolicy.ReadWrite.ConditionalAccess
Get Conditional Access PoliciesPolicy.Read.All
Delete Conditional Access PolicyPolicy.ReadWrite.ConditionalAccess

Custom Security Attributes

Operation DescriptionLeast Privileged Permissions
Create Security Attribute DefinitionCustomSecAttributeDefinition.ReadWrite.All
Get or Update Security Attribute DefinitionCustomSecAttributeDefinition.ReadWrite.All
Create Security Attribute SetCustomSecAttributeDefinition.ReadWrite.All
Get or Update Security Attribute SetCustomSecAttributeDefinition.ReadWrite.All
Assign/Remove Security Attributes for UsersCustomSecAttributeAssignment.ReadWrite.All
Assign/Remove Security Attributes for Service PrincipalsCustomSecAttributeAssignment.ReadWrite.All
Get All Security Attribute Assignments for UsersCustomSecAttributeAssignment.Read.All
Get All Security Attribute Assignments for Service PrincipalsCustomSecAttributeAssignment.Read.All

Directory & Subscription Management

Endpoints for managing Azure Directory and Subscriptions.

Operation DescriptionLeast Privileged Permissions
Get Tenant DetailsDirectory.Read.All
Get SubscriptionsDirectory.Read.All
Update/Delete SubscriptionDirectory.ReadWrite.All

Special Section: Azure-Specific Permissions

Some endpoints require Azure Role-Based Access Control (RBAC) permissions in addition to Graph API permissions. These permissions are specifically for managing Azure resources, roles, and management groups. They are different from the Microsoft Graph API permissions and need to be configured separately in Azure.

Operation DescriptionRequired Azure Role Permissions
Get TenantsMicrosoft.Resources/tenants/read
Get SubscriptionsMicrosoft.Resources/subscriptions/read
Get Management GroupsMicrosoft.Management/managementGroups/read
Get ResourcesMicrosoft.Resources/resources/read
Create/Delete Resource GroupMicrosoft.Resources/subscriptions/resourcegroups/write
Get/Delete Classic AdministratorsMicrosoft.Authorization/classicAdministrators/read
Read Role AssignmentsMicrosoft.Authorization/roleAssignments/read
Write Role AssignmentsMicrosoft.Authorization/roleAssignments/write
Delete Role AssignmentsMicrosoft.Authorization/roleAssignments/delete
Read Custom Role DefinitionsMicrosoft.Authorization/roleDefinitions/read
Write Custom Role DefinitionsMicrosoft.Authorization/roleDefinitions/write
Delete Custom Role DefinitionsMicrosoft.Authorization/roleDefinitions/delete
Update Role Assignment in Management GroupMicrosoft.Authorization/roleDefinitions/write

Reference: For more details, refer to Microsoft Graph Permissions Reference