Run command is not working on Virtual Machine

Chaitrali Deshmukh 41 Reputation points
2022-06-03T06:27:24.273+00:00

I tried to run a simple shell command : az vm run-command invoke -g vmw-hcs--edge -n vmw-hcs--edge-vm --command-id RunShellScript --scripts "mkdir chai" --debug

And received a response like this:

{
"value": [
{
"code": "ProvisioningState/succeeded",
"displayStatus": "Provisioning succeeded",
"level": "Info",
"message": "Enable succeeded: \n[stdout]\n\n[stderr]\n",
"time": null
}
]
}

I have also checked in VM, the dir is not created. I am also not clear about how run command works exactly, how can we run any custom shell scripts on the desired vms?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,124 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. srbhatta-MSFT 8,546 Reputation points Microsoft Employee
    2022-06-03T09:06:42.447+00:00

    Hello @Chaitrali Deshmukh ,
    Thanks for reaching out to Microsoft QnA. Happy to answer your question.
    You can run shell scripts via Run Command option present under VM blade, but to run these commands successfully please make sure the Guest Agent/VM agent status is in "Ready state". If the agent status is in not ready state, then the commands will not get executed.
    To run custom shell scripts on Linux VMs, navigate to Run command -> Run shell script, or use the az vm run-command invoke.

    In the above example, you have remotely created a directory called chai, and the directory gets created under the path /var/lib/waagent/run-command/download/.
    In this path, you will come across multiple directories, mostly in numbers (for eg, 1,2,3, etc), navigate to the most recently created directory, under that directory you will find the most recently created directory chai.

    I have done a repro in my lab and this is where all my remote commands are getting executed.
    Hope this helps. Please feel free to reach back in case of any queries.

    -----------------

    Please accept as answer and upvote if the information provided is helpful.