bashazureazure-cliruncommand

Storing Value file from another VM as a varible in Bash


I have a set up that needs to be bootstrapped off the values of some files in another VM.

Here is the run command I am using to invoke the run run command:

BOOT_VM="${VM_NAME}1"
BOOT_ENODE=$(az vm run-command invoke --name ${BOOT_VM} \
    --command-id RunShellScript \
    --resource-group ${RSC_GRP_NAME} \
    --query "value[].message" \
    --output tsv \
    --scripts "cat /etc/parity/enode.pub")

echo ${BOOT_ENODE}

The result I get is :

Enable succeeded: [stdout] [stderr]

As far as I know, this could mean 2 things:

  1. There is no file there
  2. I am handling the response wrongly.

Really hoping it isnt 1 and would like advice on how to approach this.


Solution

  • For your issue, there is also a reason that the agent in the vm is not at work or something not good happens to it. The Azure VM agent manages interactions between an Azure VM and the Azure fabric controller. So you should check if it works well.

    Update

    You can check the agent in the portal:

    enter image description here

    Also, you can check the agent inside the vm:

    enter image description here

    For example, I want to get the config of vim in the vm and the vm os is Red Hat 7.2. Then the result of the command az vm run-command invoke will like below:

    enter image description here