If you use az ad app update from PowerShell
$ex = "az ad app update --id ```"yourappidGUID```" --debug --reply-urls ```"https://yourSPAURL.z6.web.core.windows.net/```" ```"msalyourappidGUID://auth```""
Invoke-Expression -Command $ex
Hope this will be useful.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 921aa920-c25f-5227-aabb-49116da38fa7
- Version Independent ID: 9b5a53ad-edf8-4d89-f8e6-cde01b7866f6
- Content: az ad app
- Content Source: src/azure-cli/azure/cli/command_modules/role/_help.py
- Service: active-directory
- GitHub Login: @rloutlaw
- Microsoft Alias: routlaw
@jiasli add to S162.
Directly calling the command works fine:
az ad app update --id "yourappidGUID" --reply-urls "msalyourappidGUID://auth"
Any reason to use Invoke-Expression?
I wrote a scipt that accepts ScriptBlocks where I could use Invoke-Command it looks like that:
function global:Invoke-AzCLI {
Param(
[Parameter(Mandatory=$true, Position=0)]
[ScriptBlock]$Command)
[string]$clijson = ""
$clijson = Invoke-Command -ScriptBlock $Command
if ($LASTEXITCODE -ne 0) {
LogCLIException -LoggedText ("Az CLI command '{0}' failed. Exiting." -f $Command) -StopExecution $true
return
}
if ($clijson.Length -eq 0) {
return $null
} else {
$cliresults = ConvertFrom-Json -InputObject $clijson
return $cliresults
}
}
Fantastic. you can use Invoke-AzCLI { az ad app update ...... } However the problem is with az parameters that are "space delimited list of URIs".
- getting file not find error
- az cli reacts to --% and treats it as parameter giving invalid parameter error What you actually need is to shut up both of them az cli and PowerShell core and stop parsing everything. So Invoke-AzCLI example with scriptblock as a parameter does not work. Invoke-Expression helps. Above to answer question why Invoke-Expression.
Regarding why not simply use command line? Automation. I read Reply URLs and identifier URIs from JSON and would like to standardize my deployment scripts for the team. Team defines app registration definition in a file and does not need to rewrite all defensive code for the deployment. Automation also allows standardization of release pipeline development if no specialized release tasks components are used.
Thanks for the expalantion. But I still didn't see where the problem is. Following command works fine:
Invoke-AzCLI { az ad app update --id {}
--reply-urls "https://yourSPAURL.z6.web.core.windows.net/" "msalyourappidGUID://auth" --debug}
CLI receives the args correctly:
Command arguments: ['ad', 'app', 'update', '--id', '2a01b07a-72c5-463a-9721-7de2fe41af50',
'--reply-urls', 'https://yourSPAURL.z6.web.core.windows.net/', 'msalyourappidGUID://auth',
'--debug']
Could you provide the command to trigger file not found and --% errors?
We have a sample here to read the output of a command: https://github.com/Azure/azure-cli/blob/dev/doc/use_cli_effectively.md#windows-powershell-scrips-for-saving-to-variables-and-using-it-later
When reply URLs are provided as set of strings yes. Try doing with --reply-urls $replyurls, where $replyurls contains indicated URLs. I am trying to read $replyurls
Could you test if array works for you? I tested and CLI receives the args correctly.
> $replyurls='https://yourSPAURL.z6.web.core.windows.net/','msalyourappidGUID://auth'
> az $replyurls --debug
Command arguments: ['https://yourSPAURL.z6.web.core.windows.net/', 'msalyourappidGUID://auth', '--debug']
# also works for bare python
> python -c "import sys; print(sys.argv)" $replyurls
['-c', 'https://yourSPAURL.z6.web.core.windows.net/', 'msalyourappidGUID://auth']
Close this issue since there is no response for more than one month, please help create a new issue if you still have problem to run this command in Powershell.