Azure-cli: run-command invoke doesn't produce correct error/status fields

Created on 20 Jul 2020  路  8Comments  路  Source: Azure/azure-cli

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug
az vm run-command invoke reports success even though command execution failed

To Reproduce
Execute az vm run-command invoke --ids SOMEID --command-id RunShellScript --scripts "exit 123" or any other command that would fail

Expected behavior
Status should be failed (or error)

Environment summary

$ az --version
azure-cli (2.0.38)

Additional context
Whatever command I try to run on a Linux VM the error output field is always null and status field successed
The logs on the VM report that the program was terminated with the expected error exit status.
The message field from az cli output correctly reports the error but I'd expect the that either success or error fields would report the same.

Here's an example output from a command that doesn't exist on the system:

{
  "endTime": "2020-07-20T14:45:16.478019+00:00",
  "error": null,
  "name": "807c0bd6-8810-46ff-97f0-d56d6af52fa6",
  "output": [
    {
      "code": "ProvisioningState/succeeded",
      "displayStatus": "Provisioning succeeded",
      "level": "Info",
      "message": "Enable succeeded: \n[stdout]\n\n[stderr]\n/var/lib/waagent/run-command/download/86/script.sh: line 1: asdasd: command not found\n"
    }
  ],
  "startTime": "2020-07-20T14:44:42.274790+00:00",
  "status": "Succeeded"
}
Compute Compute - Extensions Service Attention customer-reported feature-request

All 8 comments

hi @qwordy could you pls have a look?

I think "status": "Succeeded" means the az vm run-command invoke runs successfully. The command execution failure in the VM is an expected behavior, so az vm run-command invoke does its job correctly.

So the only way to see if the script failed or not is by looking into the message field and whether there is stderr output? Using this in pipeline makes it a bit difficult to check whether the script has been successful or not. I'd expect having this kind of information saved in a separate key.

I think you are right.
The response schema is defined here https://docs.microsoft.com/en-us/rest/api/compute/virtual%20machines%20run%20commands/runcommand#runcommandresult
@Drewm3 How do you think the customer's feature request?

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @avirishuv, @axayjo, @vaibhav-agar.

@axayjo, could you take a look at this issue?

Investigating.

Tracking this as feature request as we're looking to address this in the future. The current run command implementation doesn't produce status fields.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oakeyc picture oakeyc  路  3Comments

dhermans picture dhermans  路  3Comments

cicorias picture cicorias  路  3Comments

seanknox picture seanknox  路  3Comments

ahmetb picture ahmetb  路  3Comments