question

sgrIRL avatar image
0 Votes"
sgrIRL asked ·

Convert existing VM to azure-spot

I cannot find in the documentation a mention of converting an existing VM to an azure-spot instance.
Nor can I see a way in the portal to do so, although all the relevant azure-spot information fields are showing for the VM - they just show it isn't a spot!

Can a VM be converted?

azure-virtual-machinesazure-virtual-machines-scale-setazure-spot
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@sgrIRL Is there any update? Please 'Accept as answer' if any of the replies helped, so that it can help others in the community seeing similar issue.

0 Votes 0 ·
msrini-MSFT avatar image
2 Votes"
msrini-MSFT answered ·

No, you can only set Spot pricing flag during the creation time. As of today you cannot convert the VM to Spot VM.

· 2 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Are there plans to include this ability before Azure Spot goes into General Availability?

0 Votes 0 ·

I am not sure that it will be enabled at the time of GA as well. You can provide a feature request in UserVoice

0 Votes 0 ·
LarryClaman avatar image
2 Votes"
LarryClaman answered ·

Seems like you could re-create the VM using the same technique as you would to move a VM into an availability set. (eg https://docs.microsoft.com/en-us/azure/virtual-machines/windows/change-availability-set)
I'll see if I can prototype this & will post back when I have it working

Edit: got this working. see https://gist.github.com/larryclaman/5a3bb2a7b0bb7b559b1af192469c718a

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I've put together a script that will convert an existing VM to a Spot. See:
https://gist.github.com/larryclaman/5a3bb2a7b0bb7b559b1af192469c718a

0 Votes 0 ·
DerekDaSilva-9987 avatar image
0 Votes"
DerekDaSilva-9987 answered ·

Larry- thanks for your script. I was able to use it to convert from spot to regular VM. Great job!
D

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

EdMorris-0806 avatar image
0 Votes"
EdMorris-0806 answered ·

You can also achieve the same through the web portal.

The steps are:

  1. Power down your VM from the VM summary page and wait for it to deallocate.

  2. Go DISK page of the VM, select the link for the OS disk to look at its Overview.

  3. On the overview page, click the create snapshot button to create an image of the current OS disk.

  4. Give it a name, and make the snapshot type full, selecting also Zone-redundant.

  5. Create the snapshot, taking note of its size.

  6. Navigate to the disk page from the Azure portal homepage, and in the top left of the menu bar select the add button.

  7. Create the disk as you would like, making sure the disk size is at least the size of the snapshot (it can be larger if you like). Select the source type as snapshot and select the name of the snapshot you just created.

  8. Create the disk.

  9. Navigate back to the Disks list page on the portal, and click into the new disk just created to view the overview page.

  10. On the new disks overview page, select Create VM from the horizontal menu bar, which will start a VM creation page, with the current disk as the OS disk.

  11. Be sure to select the Azure Spot Instance radio button to yes to make this a spot instance.

  12. All other options are the same as using an on-demand instance.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.