title: Storing Output of Azure CLI command as variable
body: <p>I need to store the output of an AZ cli commands that fetches my private IPs as a variable.</p>
  
  <p>I am using the following in a bash script: </p>
  
  <pre><code>echo "Fetching Monitoring Server IP"
  SERVER_IP=$(az vm show -n ${THIS_VM_NAME} -g ${RSC_GRP_NAME} --query privateIps -o tsv)
  echo "$SERVER_IP
  </code></pre>
  
  <p>It would appear that this isnt working as when I echo the variable, it comes back empty.</p>
  
  <pre><code>+ THIS_VM_NAME=XXXX-XX-XX-XX-XX
  + echo 'Fetching Monitoring Server IP'
  Fetching Monitoring Server IP
  ++ az vm show -n XXXX-XX-XX-XX-XX3 -g XXXX-XX-XX-XX-XX --query privateIps -o tsv
  + SERVER_IP=
  + echo ''
  </code></pre>
  
  <p>I will appreciate any pointers on this</p>