Azure CLI task (v1 and v2) fails due to Az CLI cosmos db commands
See original GitHub issueRequired Information
Entering this information will route you directly to the right team and expedite traction.
Question, Bug, or Feature?
Type: Bug
Enter Task Name: Azure CLI
The following is some of the task information I copied from the version 2.x
2020-01-18T09:58:50.8550617Z ==============================================================================
2020-01-18T09:58:50.8550721Z Task : Azure CLI
2020-01-18T09:58:50.8550831Z Description : Run Azure CLI commands against an Azure subscription in a PowerShell Core/Shell script when running on Linux agent or PowerShell/Powershell Core/Batch script when running on Windows agent.
2020-01-18T09:58:50.8550956Z Version : 2.0.4
2020-01-18T09:58:50.8551014Z Author : Microsoft Corporation
2020-01-18T09:58:50.8551106Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
Environment
Azure DevOps
Issue Description
When running our release pipeline tasks, Azure CLI – both v1 and v2 – fails due to issues like the one in the screenshot above.
The weird thing is that previously I was using az cosmosdb collection list --
command, and it failed because it was deprecated, and the error message said me to use az cosmosdb sql container list --
and it now fails because this command is in preview mode? What type of sorcery is that?
I guess the more appropriate place to post this question would be Azure CLI repo but I am fine with a workaround too. If there is a way to stop such messages to fail my Azure DevOps pipelines, I would take it and leave for a while.
Error Logs
I have copied the lines from the log starting from the line the error first appeared.
2020-01-18T09:59:35.1095251Z az : Command group 'cosmosdb sql' is in preview. It may be changed/removed in a future release.
2020-01-18T09:59:35.1095947Z At D:\a\r1\a\_Repo\cosmos\CreateCosmosResources.ps1:61 char:5
2020-01-18T09:59:35.1096394Z + az cosmosdb sql container list --database-name $dbName --resource ...
2020-01-18T09:59:35.1097022Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-01-18T09:59:35.1097328Z + CategoryInfo : NotSpecified: (Command group '...future release.:String) [], RemoteException
2020-01-18T09:59:35.1097635Z + FullyQualifiedErrorId : NativeCommandError
2020-01-18T09:59:35.1097911Z
2020-01-18T09:59:35.1530064Z ##[debug]Exit code 1 received from tool 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe'
2020-01-18T09:59:35.1537475Z ##[debug]STDIO streams have closed for tool 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe'
2020-01-18T09:59:35.1574278Z ##[debug]task result: Failed
2020-01-18T09:59:35.1628106Z ##[error]Script failed with error: Error: The process 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
2020-01-18T09:59:35.1638525Z ##[debug]Processed: ##vso[task.issue type=error;]Script failed with error: Error: The process 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
2020-01-18T09:59:35.1654137Z ##[debug]Processed: ##vso[task.complete result=Failed;]Script failed with error: Error: The process 'C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
2020-01-18T09:59:35.1655534Z ##[debug]which 'az'
2020-01-18T09:59:35.1692767Z ##[debug]found: 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd'
2020-01-18T09:59:35.1693188Z ##[debug]which 'az'
2020-01-18T09:59:35.1803310Z ##[debug]found: 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd'
2020-01-18T09:59:35.1803736Z ##[debug]C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd arg: account clear
2020-01-18T09:59:35.1814650Z ##[debug]C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd arg: account clear
2020-01-18T09:59:35.1817968Z ##[debug]exec tool: C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd
2020-01-18T09:59:35.1818855Z ##[debug]exec tool: C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd
Some other pieces from the log
I found this interesting so decided to copy these lines here too. They simply show a warning as well as the current Azure CLI and some other binary versions:
2020-01-18T09:59:09.4959225Z WARNING: You have 2 updates available. Consider updating your CLI installation. Instructions can be found at https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
2020-01-18T09:59:09.4960353Z azure-cli 2.0.78 *
2020-01-18T09:59:09.4967175Z
2020-01-18T09:59:09.4967572Z command-modules-nspkg 2.0.3
2020-01-18T09:59:09.4967775Z core 2.0.78 *
2020-01-18T09:59:09.4967980Z nspkg 3.0.4
2020-01-18T09:59:09.4968182Z telemetry 1.0.4
2020-01-18T09:59:09.4968327Z
2020-01-18T09:59:09.4968485Z Extensions:
2020-01-18T09:59:09.4968676Z azure-devops 0.16.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
The only way I am able to repro the error you are getting is if the standard error stream is redirected to the standard output stream, i.e. with the command (az sql container list --account-name “<ACCOUNT NAME>” --database-name “<DATABASE NAME>” --resource-group “<RESOURCEGROUP NAME>”) 2>&1 Can you let me know whether your scenario is like this? If this is your scenario, then this is an issue we had investigated earlier. The problem is with the powershell version on hosted windows 2019 agent. Once it is upgraded to a sufficient version, this issue will be resolved. Meanwhile, the workaround would be either to use hosted windows 2017 agent, or uncheck the ‘Fail on Standard Error’ option and rely on exit codes instead.
It happens the same with
webapp config access-restriction
.