azure-active-directoryazure-cliazure-ad-graph-api

Updating web redirect uri of Azure AD app registration


I have a scenario where my pipeline should update the app registration with an additional redirectUrl. I have managed to extract the current web.redirectUris with the following:

existing_urls=$(az ad app show --id '<client-id>' --query "[web.redirectUris]" --output tsv)

I would like to achieve something like this

existing_urls=$(az ad app show --id '<client-id>' --query "[web.redirectUris]" --output tsv)
az ad app update --id '<client-id>' --web-redirect-uris "$existing_urls https://hostname.com/newCallback"

I have tried updating the web.redirectUris in two ways and both of them have failed when I pass multiple redirect URIs.

Attempt 1

az ad app update --id '<client-id>' --web-redirect-uris "https://hostname.com/callbackx https://hostname.com/callbacky"

One or more properties contains invalid values.

However when having only one uri this worked fine

az ad app update --id '<client-id>' --web-redirect-uris "https://hostname.com/callbackx"

Attempt 2 This one fails regardless of number of redirectUris that are passed

az ad app update --id '<client-id>' --set "web.redirectUris=['https://hostname.com/callbackx', 'https://hostname.com/callbacky']"

Couldn't find 'web' in ''. Available options: []

Solution

  • Tried as shown :But got the same error:

    az ad app show --id 1e7bxxx7830
    
    existing_urls=$(az ad app show --id 1e7b8fxxxx830 --query "[web.redirectUris]")
    
    az ad app update --id 1e7xxx0a7830 --web-redirect-uris "$existing_urls https://hostname.com/newCallback"
    
    $updated_urls="$existing_urls https://hostname.com/newCallback"
    
    az ad app update --id 1e7b8xxx0a7830  --set "web.redirectUris='$updated_urls'"
    
    az ad app update --id 1e7b8fxxxd0a7830  --set "web.redirectUris='$updated_urls'"
    

    Error:

    Couldn't find 'web' in ''. Available options: []
    

    enter image description here

    Following command worked foe me in azure cli in updating multiple Redirect Urls:

    az ad app update --id '1e7bxxxa7830' --web-redirect-uris "https://hostname.com/callback" "https://jwt.ms" "https://myexampleapp.com"

    here --id is clientId .

    enter image description here

    So give the command with required urls as az ad app update --id '1e7bxxxa7830' --web-redirect-uris "<url1>" "<url2>" "<url3>"

    upon az ad app show --id 1e7b8xxxx830

    enter image description here