Azure-Samples/virtual-machines-python-manage

power_off() API stops a VM but it still incurs cost

whataride opened this issue · 2 comments

Is there a way to shut down a VM just as we click the 'Stop' button in the Azure portal? Right now when we call the compute_client.virtual_machines.power_off(), the machine is stopped but it still costs money. Thanks!

The operation is then "deallocate"
https://docs.microsoft.com/en-us/python/api/azure.mgmt.compute.v2017_12_01.operations.virtualmachinesoperations?view=azure-python#deallocate

Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses.

Hope this helps :)

That's exactly what I am looking for. Thanks!