Skip to content

Configure.ps1 fails in powershell (project: '2. Web API now calls Microsoft Graph') #234

Open
@jranxb70

Description

@jranxb70

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

In project '2. Web API now calls Microsoft Graph' try to utilize Configure.ps1 in AppCreationScripts. Any of the "Four ways to run the script" will do.

Any log messages given by the failure

The script will fail:

Get-AzureADUser : Error occurred while executing GetUser
Code: Request_ResourceNotFound
Message: Resource '[email protected]' does not exist or one of its queried reference-property objects are not present.
RequestId: fbc2ba74-0509-499a-9da6-ced5cbdf82ea
DateTimeStamp: Fri, 07 Apr 2023 18:53:59 GMT
HttpStatusCode: NotFound
HttpStatusDescription: Not Found
HttpResponseStatus: Completed
At line:1 char:1

  • Get-AzureADUser -ObjectId "[email protected]"
  •   + CategoryInfo          : NotSpecified: (:) [Get-AzureADUser], ApiException
      + FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.PowerShell.GetUser
    
    

Expected/desired behavior

Creating the AAD application (TodoListService(ms-identity-dotnet-native-aspnetcore-v2))
'first.last_email.com#EXT#@organization.onmicrosoft.com' added as an application owner to app 'TodoListService(ms-identity-dotnet-native-aspnetcore-v2)'
Done creating the service application (TodoListService(ms-identity-dotnet-native-aspnetcore-v2))
Getting access from 'service' to 'Microsoft Graph'
Granted permissions.
Creating the AAD application (TodoListClient(ms-identity-dotnet-native-aspnetcore-v2))
'first.last_email.com#EXT#@organization.onmicrosoft.com' added as an application owner to app 'TodoListClient(ms-identity-dotnet-native-aspnetcore-v2)'
Done creating the client application (TodoListClient(ms-identity-dotnet-native-aspnetcore-v2))
Getting access from 'client' to 'service'
Granted permissions.
Configure known client applications for the 'service'
Configured.
Updating the sample code (C:\Users\name\source_2022\repository\active-directory-dotnet-native-aspnetcore-v2\2. Web API now calls Microsoft Graph\AppCreationScripts..\TodoListService\appsettings.json)
Updating the sample code (C:\Users\name\source_2022\repository\active-directory-dotnet-native-aspnetcore-v2\2. Web API now calls Microsoft Graph\AppCreationScripts..\TodoListClient\App.Config)


IMPORTANT: Please follow the instructions below to complete a few manual step(s) in the Azure portal :


PS C:\Users\name\source_2022\repository\active-directory-dotnet-native-aspnetcore-v2\2. Web API now calls Microsoft Graph\AppCreationScripts>

OS and Version?

Windows 10 Pro

Versions

21H2

Mention any other details that might be useful

I was able to pass the problem by using my object id in the script instead of the content of $creds.Account.Id :

# Get the user running the script to add the user as the app owner
write-host $creds.Account.Id
$user = Get-AzureADUser -ObjectId 2e77dddd-aaaa-bbbb-1111-xxxxxxxxxxxxx

#$creds.Account.Id


Thanks! We'll be in touch soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions