Azure PowerShell – Starting a VM
I’ve been playing with Azure recently and decided to have a crack at a bit of automation (after being inspired by a presentation by google at Cloud Expo Europe earlier today). So to set the scene I have a small VMware environment hosted in a UK Data Centre that i run a few projects from, i’ve recently created a Virtual Machine on the Azure Cloud platform have have transferred some of the dynamic data across (SQL dumps and image uploads – using rsync), this gives me a very rudimental DR strategy. The bad news is to reduce costs if need to log onto the Azure portal, start the VM, then manually trigger the rsync, shutdown the VM and stop the service. This means i’m only paying for a few minutes of compute time not having the VM up 24/7. Having some automation would obviously work great and save me a bunch of work!
I have a Windows server already running in the Data Centre which I installed the Azure PowerShell cmdlet on after reading this informative post on the Azure website- How to install and configure Azure PowerShell.
Next I did what any techie would do and googled: “azure powershell start a VM”, after a number of attempts I couldn’t get it working using the “Start-AzureVM” command, mainly because I didn’t know or couldn’t work out what the “ServiceName” was. Well I eventually figured it out, “Start-AzureVM” applies to the old Azure Portal – apparently theres an old Portal that used to show you the service name for the VMs. Anyway, it turns out I created my VM in “Azure Resource Management mode”, so you need to use the ARM version of the command (Start-AzureRmVM) which doesn’t require a service name:
Start-AzureRmVM -Name vmname -ResourceGroupName rgname
Replace vmname and rgname with your Virtual Machine name and Resource Group name which is displayed in the Azure Portal. Hopefully this post will help anyone else out that comes across this issue to.
Next…. on with the acutal automation.