TL;TR We are creating an AAD application using the Microsoft Graph API. The application has some requiredResourceAccess entries where one requires access to microsoft graph. After we create the application we want to assign the roles to the service principal using the appRoleAssignments object. The object requires the resourceId which is the objectId (e. g. of microsoft graph) that I try to determine.
We are using the Graph API itself to get the service principals using: https://graph.windows.net/<tenant>/servicePrincipals?api-version=1.6
but somehow Microsoft Graph is missing:
Windows Azure Active Directory
Microsoft App Access Panel
Azure Classic Portal
Microsoft.SMIT
Office 365 Configure
Windows Azure Service Management API
Microsoft.SupportTicketSubmission
Azure ESTS Service
Signup
Microsoft password reset service
I need to determine the ObjectId of the Microsoft Graph Service Principal. Starting with a fresh AAD, it seems like there is no Microsoft Graph Principal:
Get-MsolServicePrincipal -AppPrincipalId 00000003-0000-0000-c000-000000000000
Output
Get-MsolServicePrincipal : Service principal was not found.
How to determine the ObjectId of Microsoft Graph (preferable using the graph.windows.net API)?
Edit 1:
As suggested by Fei Xue, creating the Service Principal via Rest using:
POST: https://graph.windows.net/{tenantId}/servicePrincipals?api-version=1.6
Authorization: Bearer {access_token}
{
"appId": "00000003-0000-0000-c000-000000000000",
"accountEnabled": true
}
Gives me a 400 (Bad Request) Error code: