In Azure AD, under the expose an API section, I'm looking to automate the registration of an API and web app using CLI 2.x. I've looked through documents here but find nothing that addresses preAuthorizedApplications. Searching has yielded only information for legacy support. Where is the CLI 2.x support for setting preAuthorizedApplications data?
When populated via the portal UI, the manifest contains the relevant information
"preAuthorizedApplications": [
{
"appId": "d22xxxxxxx",
"permissionIds": [
"ef92yyyyyy"
]
}
],...
Is this something that can be inserted into the manifest directly? Any reference to documents or samples would be greatly appreciated.
Edit: An attempt to write the property with a null value fails with error "A value without a type name was found and no expected type is available...."
az ad app update --id $appId --set preAuthorizedApplications='[]'
If I show the app properties, I see preAuthorizedApplications in the list with a null value
az ad app list --display-name $appName
So it doesn't appear that this property can be injected into the manifest for some reason.
Not sure what caused the issue, if you want to set preAuthorizedApplications
with azure cli, you could use the az rest
to call the Microsoft Graph - Update application
directly.
Sample:
az rest --method patch --uri "https://graph.microsoft.com/beta/applications/<object-id>" --headers '{"Content-Type":"application/json"}' --body '{"api":{"preAuthorizedApplications":[{"appId":"a37c1158-xxxxx94f2b","permissionIds":["5479xxxxx522869e718f0"]}]}}'
Note: You need to test the sample in the bash instead of the powershell, there are quoting issues in different terminals, if you want to run it in the powershell, you need to change the format of the headers
and body
, see https://github.com/Azure/azure-cli/blob/dev/doc/use_cli_effectively.md#quoting-issues
I test it directly in the Bash
of Azure Cloud Shell, it works fine:
Check in the portal: