Querying prices for Azure Spot VMs

Mark Whitney 81 Reputation points
2020-01-04T00:40:36.503+00:00

Is there a way to query the current Azure Spot VM price for a specific VM family/type + region?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,124 questions
0 comments No comments
{count} vote

Accepted answer
  1. msrini-MSFT 9,256 Reputation points Microsoft Employee
    2020-01-06T05:59:05.283+00:00

    Hi,

    Azure Spot VMs pricing are not constant and the pricing changes periodically. As of now, there are no established API available for the consumers to check the current pricing for Spot instances.

    But you can check the pricing from Azure portal. You need to select Create New VM --> Select Region and Azure Spot to Yes --> Click on Change Size.

    You can see the current price for each size in the region which you have selected.


1 additional answer

Sort by: Most helpful
  1. MarkScu 26 Reputation points
    2020-10-13T00:05:07.05+00:00

    There's now a public API that will return pricing, including that for Spot VMs - https://learn.microsoft.com/rest/api/cost-management/retail-prices/azure-retail-prices

    The result set is large, so I'd highly recommend using filtering to only request prices for VMs and Consumption pricing; e.g. https://prices.azure.com/api/retail/prices?$skip=0&$filter=serviceName%20eq%20%27Virtual%20Machines%27%20and%20priceType%20eq%20%27Consumption%27

    The API does return the results in batches (up to 100 at a time when I tried), so you'll need a mechanism to handle paging to get all the results.

    5 people found this answer helpful.
    0 comments No comments