azure-cli: Writing to `stderr` causes failure on pipeline tasks with `failOnStderr` set to `true`
Describe the bug We have been noticing the following warning after upgrading from Az Cli 2.0.73 to 2.24 in our pipeline operation for purging AFD cache. It is causing the pipeline to fail. The operation depends on an extension of Az Cli called “front-door”, although I have tried reverting the extension to original version (1.0.2) and the warning still persists.
Can you please help us identify if this is something related to the pipeline agent itself or Az Cli? It looks like doing some telemetry check. Also, I don’t see this kind of check when I test the operation locally on my devbox with --debug flag.

To Reproduce Run
az network front-door purge-endpoint --resource-group <RG-NAME> --name <NAME> --content-paths /* --debug
Expected behavior No warnings.
Environment summary Az Cli version: 2.24 front-door extension version: 1.0.14, 1.0.2 Pipeline agent pools are running Windows_NT
Additional context Link to error message within a pipeline failure: Link
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (9 by maintainers)
Warning type output for warnings, rather than error type, seems so much more logical here… while it could be concieve as “diagnostics”… the use of diagnostics in that context of the documentation is meant to be diagnostics issued by the program in regards to an error… not general diagnostics.
(Copied from https://github.com/Azure/azure-cli/issues/19314#issuecomment-917784104)
According to https://www.gnu.org/software/libc/manual/html_node/Standard-Streams.html
Therefore,
stderris the right place for Azure CLI to write WARNING messages.If the pipeline has
failOnStderrset totrueand the WARNING message is causing failure, you may eitherfailOnStderrtofalse.--only-show-errorsflag oronly_show_errorsconfig option: https://learn.microsoft.com/en-us/cli/azure/azure-cli-configuration#cli-configuration-values-and-environment-variablesfailOnStderr: truemeans as long as there is something printed tostderr, the pipeline fails:https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/bash?view=azure-devops#arguments
It doesn’t distinguish whether the log message is DEBUG, INFO, WARNING, ERROR. These are Azure CLI’s own classification.
If you want to use
--debugwhich prints all log messages tostderr,failOnStderrmust be set tofalse. In other words,--debugandfailOnStderrare mutually exclusive.The correct way to detect if a CLI command fails is to check the exit code. In Bash, you can utilize
set -ewhich automatically fails the script when a CLI command fails:https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
@rajarshi-singh , the pipeline link you shared is not available. Also the warning seems related to azure CLI telemetry upload and not related to Azure Front Door extension: https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-telemetry/azure/cli/telemetry/util.py#L35-L37
I am not sure whether this should be treated as a warning or not, @yonzhan could provide more details for that.
Anyway, if the warning is really an issue, you might consider to disable the telemetry collecting with:
az configure -d collect_telemetry=falseaccording to azure-cli-configuration