0

Need a way to catch az lab * failures.

One example where I need to do this is when I am creating a lab using az lab vm create. This is failing at times (probably because of unavailability of resources) and I want to catch it right away and not execute the rest of the code which assumes that the VM has been created.

Unfortunately it just prints it on console (not very helpful if there is noone staring at the screen when this is executing).

Can I get some thing to

Shui shengbao
  • 18,746
  • 3
  • 27
  • 45
Pranav Raj
  • 781
  • 1
  • 8
  • 19

1 Answers1

0

The command should have a non-zero exit code if the command fails. Depending on which shell/command window you are using, there are different mechanisms for checking the return value of a command. For example, in bash, you can use set -e to control how the script should handle a failure. Or, in cmd.exe, you can check the ERRORLEVEL.