I use the Azure CLI task on my Azure classic pipeline (no YAML). The pipeline works appropriately, the only problem is that this task shows an error. I use this inline script for the task:
$containers = $(call az storage container list --connection-string '...') | ConvertFrom-Json -Depth 5
$containers | where{$_.name -like "..."}
$lastContainers = $containers | Select-Object -Last 5
$containers.ForEach({ If ($_ -notin $lastContainers) {call az storage container delete --name $_.name --connection-string '...' } });
I replaced my real connection string with ...
. I get this error about the last task (Azure CLI) when I run the pipeline (all of the previous steps end successfully):
D:\a\9\s>$containers = $(call az storage container list --connection-string '...') | ConvertFrom-Json -Depth 5
'$containers' is not recognized as an internal or external command, operable program or batch file.
##[error]Script failed with error: Error: The process 'D:\a\_temp\azureclitaskscript1587632019088.bat' failed with exit code 255
I have a similar YAML pipeline that uses this same script and everything works just fine. I use call
in front of Azure commands as suggested on GitHub.