When driving down the street I think we all know what to do when we see a Stop Sign – we know we need to stop the car. What happens when you see Stopped as a status for a Windows Azure Virtual Machines? A little over a month ago Microsoft announced they would no longer charge for a Stopped Virtual Machine. This came as welcome news as I am sure many of you are like me – have left something on for a few days and received a bill for it. What Microsoft introduced was really a new definition of Stopped to go along with the existing process they had in place. We now have the following two definitions:
|
When you create a Virtual Machine inside Windows Azure you get a Cloud Service to basically host that virtual machine role. You can add more than one Virtual Machine to that Cloud Service and would do so to achieve high availability.
Up until a few days ago, that Cloud Service was always hidden from the Windows Azure Management Portal. You could see it when you deleted the last virtual machine in the service or using PowerShell. Now, you can see the services inside the UI – so that should help with the confusion. The Cloud Service, along with other things, is what gives your Virtual Machine a Virtual IP address (VIP).
In the pictures below you can see a few of my Virtual Machines and Cloud Services in the Stopped and Stopped Deallocated state.
What’s the difference between Stopped and Stopped– Deallocated?
Stopped $$$ – When a virtual machine is stopped you are still being charged for the virtual machine. You also have the Virtual IP (VIP) address reserved and when you start the machine back up again you will get the same VIP. This is useful when you must have the same VIP.
Stopped Deallocated – When a virtual machine is stopped deallocated you are no longer charged for the virtual machine. The catch is, when you start it back up you might not get the same VIP back again. You get a message about this when you stop the Virtual Machine.
For all the work I am doing right now, the Stopped Deallocated state works just fine for me.
See below on how to get your Virtual Machine into a Stopped or Stopped Deallocated state.
How to Stop a Virtual Machine ($$$)
- PowerShell
- Stop-AzureVM -Name $VirtualMachineName -ServiceName $ServiceName –StayProvisioned (StayProvisioned is new in PowerShell as of 06/13)
- Selecting Shut Down while logged into the Virtual Machine
- REST API
- Example: https://management.core.windows.net/<subscription-id>/services/hostedservices/swt003-sql01/deployments/swt003-sql01/roleInstances/swt003-sql01/Operations
How to Stop – Deallocate a Virtual Machine (Money Saver!!!!)
- PowerShell
- Stop-AzureVM -Name $VirtualMachineName -ServiceName $ServiceName –Force (Note if you don’t use –Force you get an annoying confirmation popup)
- Using the Windows Azure Management Portal
- You will get a confirmation informing you the Virtual IP will be released
Please post if I have missed any other ways to stop a Virtual Machine.
How are you using Windows Azure Virtual Machines? Does the Stopped Deallocated state work for you?
You can Stop – Deallocate with the REST API with a (so far) undocumented version see details here: http://stackoverflow.com/questions/19065253/how-to-start-azure-vmdeallocated-use-rest-api
A Deallocated VM return 404 when you try to get the deployment status. :\
In order to avoid loosing the IP Address of virtual machine, when stopping + deallocating, you can just keep IP address you want by reservating it.
Here is how I do it
$staticVM = Get-AzureVM -ServiceName “your-cloud-service-name” -Name “your-vm-name”
Set-AzureStaticVNetIP -VM $staticVM -IPAddress 10.0.0.4 | Update-AzureVM
@Massimo – great feedback! This is a few feature that was release after this initial post. Thanks for helping keep this up to date!
From the GUI – if you click on shutdown on an alread ‘shutdown’ machine that isn’t deallocated, it will go ahead and deallocate it for you, the machine then shows up as ‘shutdown – deallocated’ .
One question, can you issue shutdown commands through powershell for multiple servers at the same time, the GUI only allows sequential (ie you can’t click shutdown on one machine, then before it finishes, shutdown another).
Mark