Skip to content

Instantly share code, notes, and snippets.

@superscott
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superscott/16a663a21dfd4b6fb2bd to your computer and use it in GitHub Desktop.
Save superscott/16a663a21dfd4b6fb2bd to your computer and use it in GitHub Desktop.
check if azure vm is running.....
#!/bin/bash
# Pass the vm name as the first argument
vm_name=$1
# Check to make sure the VM is Present (in a silly way).
# data = good, warn = bad.
vm_exist=`azure vm show $vm_name | awk '{print $1}'| uniq | sed 's/://g' | grep warn`
# Default Time Output for Pretty Print.
now=`date +%r`
if [ -n "$vm_exist" ]
then
echo "$now :: !! $vm_name does NOT exist !!"
exit 1
else
while state=`azure vm list | awk '{print $2, $3}' | grep $vm_name | awk '{print $2}'`
do
if [ $state = 'ReadyRole' ]
then
echo "$now :: VM $vm_name is Ready!"
break
else
now=`date +%r`
echo "$now :: VM $vm_name not Ready :: Trying again in 60 Seconds"
sleep 60
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment