powershell - Missing Microsoft Graph ServicePrincipal -


tl;tr creating aad application using microsoft graph api. application has requiredresourceaccess entries 1 requires access microsoft graph. after create application want assign roles service principal using approleassignments object. object requires resourceid objectid (e. g. of microsoft graph) try determine.

we using graph api service principals using: https://graph.windows.net/<tenant>/serviceprincipals?api-version=1.6 somehow microsoft graph 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 determine objectid of microsoft graph service principal. starting fresh aad, seems there no microsoft graph principal:

get-msolserviceprincipal -appprincipalid 00000003-0000-0000-c000-000000000000 

output

get-msolserviceprincipal : service principal not found. 

how determine objectid of microsoft graph (preferable using graph.windows.net api)?


edit 1:

as suggested fei xue, creating 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 400 (bad request) error code:

enter image description here

i need determine objectid of microsoft graph service principal. starting fresh aad, seems there no microsoft graph principal:

the service principal of multi-tenant app(microsoft graph) register on other tenant created after user grant consent app. reason why not able find in fresh tenant.

to object id of microsoft graph, need register , grant permission of microsoft graph figure below:

enter image description here

after get-msolserviceprincipal command should works you(note: may need wait few seconds after grant permission).

more detail service principal, can refer this document.

update

post: https://graph.windows.net/{tenantid}/serviceprincipals?api-version=1.6  authorization: bearer {access_token}  {   "appid": "00000003-0000-0000-c000-000000000000",   "accountenabled": true } 

update2

the above rest using app(1950a258-227b-4e31-a9cf-717495945fc2) register on microsoft tenant acquire token. create service principal microsoft graph pragmatically, can call new-azurermadserviceprincipal command.

here c# code sample works me:

try {     var username = "";     var password = "";     var securepassword = new securestring();     foreach (char c in password)     {         securepassword.appendchar(c);     }      // create initial session state runspace.     initialsessionstate initialsession = initialsessionstate.createdefault();     // create credential object.     pscredential credential = new pscredential(username, securepassword);     // create command log in azure.     command connectcommand = new command("login-azurermaccount");     connectcommand.parameters.add((new commandparameter("credential", credential)));     // create command create service principal.     command createsp = new command("new-azurermadserviceprincipal");     createsp.parameters.add(new commandparameter("applicationid", "00000003-0000-0000-c000-000000000000"));     using (runspace psrunspace = runspacefactory.createrunspace(initialsession))     {         // open runspace.         psrunspace.open();          //iterate through each command , executes it.         foreach (var com in new command[] { connectcommand, createsp})         {             var pipe = psrunspace.createpipeline();             pipe.commands.add(com);             pipe.invoke();          }         // close runspace.         psrunspace.close();     } } catch (exception) {     throw; } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -