Convert existing VM to azure-spot

sgrIRL 6 Reputation points
2019-12-06T08:16:09.743+00:00

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 Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
5,240 questions
Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
253 questions
{count} vote

4 answers

Sort by: Most helpful
  1. msrini-MSFT 6,856 Reputation points Microsoft Employee
    2019-12-06T09:09:28.883+00:00

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

    2 people found this answer helpful.

  2. Larry Claman 16 Reputation points
    2020-04-07T13:34:31.497+00:00

    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://learn.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

    2 people found this answer helpful.

  3. Ed Morris 36 Reputation points
    2020-06-01T11:01:52.943+00:00

    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.
    2 people found this answer helpful.
    0 comments No comments

  4. Derek Da Silva 1 Reputation point
    2020-05-04T20:43:14.407+00:00

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

    0 comments No comments