Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Use Azure Spot Virtual Machines

Feedback

In this article

Applies to: ✔️ Linux VMs ✔️ Windows VMs ✔️ Flexible scale sets ✔️ Uniform scale sets

Using Azure Spot Virtual Machines allows you to take advantage of our unused capacity at a significant cost savings. At any point in time when Azure needs the capacity back, the Azure infrastructure will evict Azure Spot Virtual Machines. Therefore, Azure Spot Virtual Machines are great for workloads that can handle interruptions like batch processing jobs, dev/test environments, large compute workloads, and more.

The amount of available capacity can vary based on size, region, time of day, and more. When deploying Azure Spot Virtual Machines, Azure will allocate the VMs if there's capacity available, but there's no SLA for these VMs. An Azure Spot Virtual Machine offers no high availability guarantees. At any point in time when Azure needs the capacity back, the Azure infrastructure will evict Azure Spot Virtual Machines with 30-seconds notice.

YouTube video about Spot VMs and reducing operational costs of stateless workloads.

Eviction policy

Spot VMs can be stopped if Azure needs capacity for other pay-as-you-go workloads or when the price of the spot instance exceeds the maximum price that you have set. When creating an Azure Spot Virtual Machine, you can set the eviction policy toDeallocate (default) orDelete.

TheDeallocate policy moves your VM to the stopped-deallocated state, allowing you to redeploy it later. However, there's no guarantee that the allocation will succeed. The deallocated VMs will count against your quota and you'll be charged storage costs for the underlying disks.

If you would like your VM to be deleted when it's evicted, you can set the eviction policy todelete. The evicted VMs are deleted together with their underlying disks, so you'll not continue to be charged for the storage.

You can opt in to receive in-VM notifications throughAzure Scheduled Events. These are delivered on a best effort basis up to 30 seconds prior to the eviction.

OptionOutcome
Max price is set to >= the current price.VM is deployed if capacity and quota are available.
Max price is set to < the current price.The VM isn't deployed. You'll get an error message that the max price needs to be >= current price.
Restarting a stopped/deallocated VM if the max price is >= the current priceIf there's capacity and quota, then the VM is deployed.
Restarting a stopped/deallocated VM if the max price is < the current priceYou'll get an error message that the max price needs to be >= current price.
Price for the VM has gone up and is now > the max price.The VM gets evicted. Azure will attempt scheduled event delivery up to 30 seconds before actual eviction.
After eviction, the price for the VM goes back to being < the max price.The VM won't be automatically restarted. You can restart the VM yourself, and it will be charged at the current price.
If the max price is set to-1The VM won't be evicted for pricing reasons. The max price will be the current price, up to the price for standard VMs. You'll never be charged above the standard price.
Changing the max priceYou need to deallocate the VM to change the max price. Deallocate the VM, set a new max price, then update the VM.

Tip

Check out ourAzure Virtual Machine Spot Eviction guide to learn how to create a reliable interruptible workload in Azure.

Limitations

The following VM sizes aren't supported for Azure Spot Virtual Machines:

  • B-series
  • Promo versions of any size (like Dv2, NV, NC, H promo sizes)

Azure Spot Virtual Machines can be deployed to any region, except Microsoft Azure operated by 21Vianet.

The followingoffer types are currently supported:

  • Enterprise Agreement
  • Pay-as-you-go offer code (003P)
  • Sponsored (0036P and 0136P) - not available in Fairfax
  • For Cloud Service Provider (CSP), see thePartner Center or contact your partner directly.

Pricing

Pricing for Azure Spot Virtual Machines is variable, based on region and SKU. For more information, see VM pricing forLinux andWindows.

You can also query pricing information using theAzure retail prices API to query for information about Spot pricing. ThemeterName andskuName will both containSpot.

With variable pricing, you have option to set a max price, in US dollars (USD), using up to five decimal places. For example, the value0.98765would be a max price of $0.98765 USD per hour. If you set the max price to be-1, the VM won't be evicted based on price. The price for the VM will be the current price for spot or the price for a standard VM, which ever is less, as long as there's capacity and quota available.

Pricing and eviction history

Portal

You can see historical pricing and eviction rates per size in a region in the portal while you are creating the VM. After selecting the checkbox toRun with Azure Spot discount, a link will appear under the size selection of the VM titledView pricing history and compare prices in nearby regions. By selecting that link you will be able to see a table or graph of spot pricing for the specified VM size. The pricing and eviction rates in the following images are only examples.

Tip

Eviction rates are quotedper hour. For example, an eviction rate of 10% means a VM has a 10% chance of being evicted within the next hour, based on historical eviction data of the last 7 days.

Chart:

Screenshot of the region options with the difference in pricing and eviction rates as a chart.

Table:

Screenshot of the region options with the difference in pricing and eviction rates as a table.

Azure Resource Graph

You can programmatically access relevant Spot VM SKU data throughAzure Resource Graph. Get pricing history in the last 90 days and eviction rates for the last 28 trailing days to identify SKUs that better meet your specific needs.

Key benefits:

  • Query Spot eviction rates and the last few months of Spot prices programmatically through ARM or theARG Explorer in Azure portal
  • Create a custom query to extract the specific data relevant to your scenario with the ability to filter across a variety of parameters, such as SKU and region 
  • Easily compare data across multiple regions and SKUs 
  • Find a different Spot SKU or region with a lower price and/or eviction rate 

Try out the following sample queries for Spot pricing history and eviction rates using theARG Explorer in Azure portal. Spot pricing history and eviction rates data are available in theSpotResources table. 

Spot pricing history sample query:

SpotResources | where type =~ 'microsoft.compute/skuspotpricehistory/ostype/location' | where sku.name in~ ('standard_d2s_v4', 'standard_d4s_v4') | where properties.osType =~ 'linux' | where location in~ ('eastus', 'southcentralus') | project skuName = tostring(sku.name), osType = tostring(properties.osType), location, latestSpotPriceUSD = todouble(properties.spotPrices[0].priceUSD) | order by latestSpotPriceUSD asc

Spot eviction rates sample query:

SpotResources | where type =~ 'microsoft.compute/skuspotevictionrate/location' | where sku.name in~ ('standard_d2s_v4', 'standard_d4s_v4') | where location in~ ('eastus', 'southcentralus') | project skuName = tostring(sku.name), location, spotEvictionRate = tostring(properties.evictionRate) | order by skuName asc, location asc

Alternatively, try out theARG REST API to get the pricing history and eviction rate history data.

Frequently asked questions

Q: Once created, is an Azure Spot Virtual Machine the same as regular standard VM?

A: Yes, except there's no SLA for Azure Spot Virtual Machines and they can be evicted at any time.

Q: What to do when you get evicted, but still need capacity?

A: We recommend you use standard VMs instead of Azure Spot Virtual Machines if you need capacity right away.

Q: How is quota managed for Azure Spot Virtual Machines?

A: Azure Spot Virtual Machines will have a separate quota pool. Spot quota will be shared between VMs and scale-set instances. For more information, seeAzure subscription and service limits, quotas, and constraints.

Q: Can I request for additional quota for Azure Spot Virtual Machines?

A: Yes, you'll be able to submit the request to increase your quota for Azure Spot Virtual Machines through thestandard quota request process.

Q: Where can I post questions?

A: You can post and tag your question withazure-spot atQ&A.

Q: How can I change the max price for a spot VM?

A: Before you can change the max price, you need to deallocate the VM. Then you can change the max price in the portal, from theConfiguration section for the VM.

Q: Can I convert existing VMs to Spot VMs?

A: No, setting the Spot flag is only supported at creation time.

Q: Can I convert Spot VMs to Standard VMs?

A: No, Spot VMs cannot be directly converted to Standard VMs.

Next steps

Use theCLI,portal,ARM template, orPowerShell to deploy Azure Spot Virtual Machines.

You can also deploy ascale set with Azure Spot Virtual Machine instances.

If you encounter an error, seeError codes.


Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?