Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jranxb70 opened this issue Apr 8, 2023 · 0 comments

Comments

@jranxb70
Copy link

jranxb70 commented Apr 8, 2023

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 'first.last@email.com' 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 "first.last@email.com"
  •   + 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants