0

Does anyone know of a simple command to deprovision an Azure VM from a batch file on the guest machine?

Something like the Windows 'shutdown' command, but which will deprovision the VM so I'm no longer charged for it.

I found the Stop-AzureVM PowerShell cmdlet, but this requires a -ServiceName parameter, which I'm not sure of the value - I created the VM through the Azure Portal and can't see which value I'm supposed to use for this.

Does anyone know of an all purpose sequence of commands which will deprovision the current Azure VM?

Thanks Pete

  • Can you tell if it's a classic VM or a Resource Manager VM type? you should be able to tell from the Azure Portal – Noor Khaldi Jan 28 '17 at 17:25
1

Azure has two types of VM resources (amongst other things). Classic and ARM (Azure Resource Manager). Classic, as the name implies, is the older version of the infrastructure which uses cloud services. ARM is the new version and if you just created a VM from the portal with teh defaults this is what you will have got.

To de-allocate that VM so your not charged then you should use the Stop-AzureRMVM command, this requires the name of the VM and the resource group it is in, you should be able to see this from the portal.

Stop-AzureRmVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"
  • That makes sense now, I do know the resource group name - so this should work, many thanks! – Pete Jan 29 '17 at 17:51
  • Does anyone know if this is possible from a linux machine? I've found, that there should be a linux version of the azure cli accessible in the linux images provided by azure, but I am unable to find any documentation. – JaKu Jan 29 at 10:49
  • If you mean can you run a command from a Linux command line to stop a VM, yes. You can either use the Azure CLI which is cross-platform, or the new Az PowerShell core cmdlets, which are cross-platform – Sam Cogan Jan 29 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.