Reputation: 115
After I created an app I add admin-consent - but it failed on last line
$myApiAppRegistration = az ad app create --display-name $appName --password $secret --reply-urls $replyUrl --required-resource-accesses $resources --available-to-other-tenants false
$myApiAppRegistrationResult = ($myApiAppRegistration | ConvertFrom-Json)
az ad app permission admin-consent --id $myApiAppRegistrationResult.appId
If run this command in the shell - it works fine.
Write-Host ' Create Service Principal'
Start-Sleep -Seconds 5
az ad sp create --id $appId
Start-Sleep -Seconds 5
Write-Host ' Add Permission grant'
az ad app permission grant --id $appId --api $graphId
Start-Sleep -Seconds 5
Write-Host ' Admin consent. AppId:' $appId
az ad app permission admin-consent --id $appId
Upvotes: 1
Views: 531
Reputation: 115
Before granting consent I have to:
-- Service Principal
az ad sp create --id $appId |Out-Null
-- Grant Permissions
az ad app permission grant --id $appId --api $graphId
Upvotes: 0
Reputation: 42043
Use az account show
to make sure you logged in the correct admin account in the powershell, and try to specify the --identifier-uris
when you creating the app.
$myApiAppRegistration = az ad app create --display-name $appName --password $secret --reply-urls $replyUrl --identifier-uris 'https://testapp777' --required-resource-accesses $resources --available-to-other-tenants false
Upvotes: 1