I am trying to run a PowerShell script for assigning appRoles from a DevOps service principal.
The DevOps service principal has the following permissions assigned and admin consented:
- Application.Read.All
- AppRoleAssignment.ReadWrite.All
- User.Read
It fails on the step where it gets the service principal which is the owner of the roles to assign:
$sp = Get-AzureADServicePrincipal -filter "displayName eq '$AppName'"
with the error message:
Error occurred while executing GetServicePrincipals
Code: Authorization_RequestDenied
Message: Insufficient privileges to complete the operation.
RequestId: a8fadf67-94d6-40ec-ad88-6562cf9f6d80
DateTimeStamp: Tue, 23 Jun 2020 16:51:36 GMT
HttpStatusCode: Forbidden
HttpStatusDescription: Forbidden
HttpResponseStatus: Completed
I expected Application.Read.All to grant this permission, since the resource I am searching for is an Application.
What permission do I need to run this line of script, and where is this documented? I am applying the principle of least-privilege and don't want to give the Devops sp an administrative role. I only want to apply the specific permission required to do the job.
