Azure-docs: Capture az cli command failure

Created on 21 May 2020  Â·  5Comments  Â·  Source: MicrosoftDocs/azure-docs

If any az command like 'az artifacts universal download *' or 'az artifacts universal publish *' fails, how to capture error code at bash?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 azursvc cxp product-question triaged

All 5 comments

@contactvikasgupta Thanks for your question. We are checking on this and will respond to you soon.

@contactvikasgupta Apologies for delayed response.

If you want to capture just the error code, after you run the az command try to run echo $? for getting the error code.

Please try below commands on bash to capture the az cli command verbose output into file
command >outfile.txt 2>&1 this will redirect both stdout and stderr to the outputfile.
command > outfile.txt 2> error.txt if you want them separated.
​

@contactvikasgupta We will now proceed to close this thread. If there are further questions regarding this matter, please comment and we will gladly continue the discussion.

Thanks, this worked.

@contactvikasgupta Thank you for the confirmation.

Was this page helpful?
0 / 5 - 0 ratings