-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Cannot pass PowerShell array as $mylist
to Azure CLI
#23797
Comments
@jiasli for awareness |
This error is not a breaking change. Previously that
The entry script The correct way to pass a list as multiple arguments is to use > $mylist = "a", "b"
> az --debug @mylist
cli.knack.cli: Command arguments: ['--debug', 'a', 'b']
# This is wrong
> az --debug $mylist
cli.knack.cli: Command arguments: ['--debug', 'a b'] |
Sometimes
Instead, use
|
Thank you so much! This is exactly the help we needed. |
Similarly, argument names can also be included in the array: > $Params = @(
'keyvault', 'network-rule', 'add',
'--resource-group', 'ResourceGroupName',
'--name', 'KeyVaultName',
'--ip-address', 'IPAddress'
)
> az --debug @Params
DEBUG: cli.knack.cli: Command arguments: ['--debug', 'keyvault', 'network-rule', 'add', '--resource-group', 'ResourceGroupName', '--name', 'KeyVaultName', '--ip-address', 'IPAddress'] Note: Don't really put |
--web-redirect-uris
multiple URIs with Powershell variable$mylist
to Azure CLI
Related command
az ad app update
Describe the bug
--Using Powershell--
Adding a redirect URI to an app is common practice for us.
--web-redirect-uris
is rather particular with how values are given to it. As of 2.37 with the migration ofaz ad
to Microsoft Graph API, we use the following script to append a single URI to the list and it's worked pretty well:This has been sufficient until 2.40, where this no longer works. I have not been able to figure out a way to pass multiple URIs in a Powershell variable to
--web-redirect-uris
.To Reproduce
Use Az CLI 2.39:
a. I.e.,
https://site1.example.com/signin-oidc
,https://site2.example.com/signin-oidc
$newRedirectUri
variable (or similar), and run the script snippet.$redirectUris
should appear like so when printed to console:Try again with Az CLI 2.40. It no longer works:
One or more properties contains invalid values.
Expected behavior
At least in Powershell, each URI must be wrapped in quotes. Double quotes works for us because we're using vars. This is achieved with line 4 of the script. Each URI must also be space separated as per the documentation. The
$redirectUris
variable is an array, however Powershell appears to just print out each URI sequentially when the command is run. It behaves like so:az ad app update --id $AppId --web-redirect-uris "https://site1.example.com/signin-oidc" "https://site2.example.com/signin-oidc" "https://site3.example.com/signin-oidc" "https://site4.example.com/signin-oidc"
This satisfies the command as of 2.39.
Environment summary
Az CLI 2.40, Windows 11, Powershell 7
Additional context
There does not appear to be any changes to
az ad
for 2.40 according to the release notes.The
--set
flag doesn't appear to be much use either. Perhaps I am using it wrong, but that's outside of the scope of this issue.(If someone knows how to update redirect URIs using
--set
, I'd love to know how!The text was updated successfully, but these errors were encountered: