As the service principal is the identity that the Azure AD SCIM app service runs as it calls Microsoft Graph, you need to assign to the service principal permissions required for your use case. You assign these permissions using the Azure CLI, which is a command-line tool that use to connect to Azure and execute administrative commands on Azure resources.
...
Install Azure CLI on your machine (if not already installed). For instructions, see Install the Azure CLI for Windows | Microsoft Docs.
Sign in to your tenant with Azure CLI using .
Open an administrative command prompt or PowerShell session and set assign permissions to the service principal for your use case. Create an application in Azure AD and associate it with the certificate you generated in EmpowerIDrun the permissions script included in this topic.
Install Azure CLI
If Azure CLI is not installed on your machine, please see Microsoft’s instructions for doing so here: Install the Azure CLI for Windows | Microsoft Docs. Once you install the CLI, sign in to your tenant with the Azure CLI using the credentials of a user with adequate permissions to execute the permissions script in Azure AD (owner at the tenant level).grant the service principal the appropriate access in Azure by running the permissions script shown in the Set Graph API Permissions section of this article.
Set Graph API Permissions
To set Graph API permissions, sign , execute the below script in either an administrative command prompt or PowerShell session. When executing the script, Azure prompts you to log in to your tenant with the Azure CLI using . Be sure to authenticate with the credentials of a user with adequate who can add Microsoft Graph permissions to execute the script in Azure AD the App Service managed identity (owner at the tenant level) and then execute the script against the tenant. run the below script in either an administrative command prompt or PowerShell session. The script
Permissions follow the least-privilege principle and include the following for managing Azure Licenses:
Table 1: Permissions needed to manage Azure licenses in EmpowerID.
The default script assigns the permissions listed in Table 1 to the managed identity. Before executing the script, change the permissions as needed for your scenario. For example, one of the permissions being assigned is Directory.Read.All
. This allows the app to read data in your organization's directory, such as users, groups, and apps. If you want both to read and write data in your organization's directory, such as creating and deleting Azure users and groups in EmpowerID, then you would change the permission to Directory.ReadWrite.All
.
Table 1: Default Permissions included with the Permissions script. Change the permissions from Read to ReadWrite according to your needs. For example, change GroupMember.Read.All to GroupMember.ReadWrite.All if you want to both read and update group memberships in EmpowerID.
Graph API / Permissions name | Access Granted by Permissions | Used By |
AuditLog.Read.All | Read audit log data | App Service Managed Identity |
Group.Read.All | Read group data | App Service Managed Identity |
GroupMember.ReadWriteRead.All | Read and write group memberships | App Service Managed Identity |
User.Read.All | Read user profile | App Service Managed Identity |
Reports.Read.All | Read report data | App Service Managed Identity |
Organization.Read.All | Read organization information | App Service Managed Identity |
Policy.Read.lAllAll | Read your organization’s policies | App Service Managed Identity |
Policy.ReadWrite.ConditionalAccess | Read and write your organization’s conditional access policies | App Service Managed Identity |
Domain.Read.All | List domains | App Service Managed Identity |
Directory.Read.All | Read data in your organization’s directory, such as users, groups and apps | App Service Managed Identity |
Application.Read.All | Read applications and service principals | App Service Managed Identity |
In addition to adding the permissions, you need to enter values for the below parameters:
...
Tip |
---|
When running the script, be Azure will open your default browser and prompt you for credentials. Be sure to authenticate to Azure as a user with adequate permissions to execute it in Azure AD (owner at the tenant level). Once you have authenticated, the rest of the script will execute. |
Code Block | ||
---|---|---|
| ||
az login $webApp=<"<WebWeb-App-Name>Name"> $sprincipal_id=$(az resource list -n $webApp --query [*].identity.principalId --out tsv) $graphResourceId=$(az ad sp list --display-name "Microsoft Graph" --query [0].objectId --out tsv) $uri="https://graph.microsoft.com/v1.0/servicePrincipals/$sprincipal_id/appRoleAssignments" $PermissionsToAdd = @("RoleManagement.ReadWrite.Directory","Directory.ReadWriteRead.All","Organization.Read.All", "User.Read.All", "Group.Read.All", "GroupMember.ReadWriteRead.All", "Reports.Read.All", "AuditLog.Read.All","Policy.Read.All","Policy.ReadWrite.ConditionalAccess","Application.Read.All","Domain.Read.All" ) $PermissionsToAdd | foreach { $appRoleId=$(az ad sp list --display-name "Microsoft Graph" --query "[0].appRoles[?value=='$($_)' && contains(allowedMemberTypes, 'Application')].id" --output tsv) $body="{'principalId':'$sprincipal_id','resourceId':'$graphResourceId','appRoleId':'$appRoleId'}" az rest --method post --uri $uri --body $body --headers "Content-Type=application/json" } |
Page Properties | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Set Azure REST API PermissionsIf you are managing Azure roles and management groups in EmpowerID, in addition to setting the above permissions for license management via PowerShell, you need to add the below permissions scoped to the appropriate Azure subscription(s) you want to manage in EmpowerID. These permissions allow EmpowerID to call the relevant Azure REST API endpoints needed to manage Azure roles and management groups. Table 2: Permissions needed to manage Azure roles in EmpowerID
The permissions needed to manage Azure licenses have been added to the script's PermissionsToAdd parameter, shown below. To add permissions for role management, add the permission name from the Azure REST API / Permissions name column of Table 2: Permissions needed to manage Azure roles in EmpowerID. In addition to adding the permissions, you need to enter values for the below parameters:
To set the Azure REST API Permissions for the target subscription, do the following:
|
...
Next Steps
Connect EmpowerID to Azure Active Directory
...