You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/batch/batch-spot-vms.md
+85-46Lines changed: 85 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Run Batch workloads on cost-effective Spot VMs
3
3
description: Learn how to provision Spot VMs to reduce the cost of Azure Batch workloads.
4
4
ms.topic: how-to
5
-
ms.date: 02/23/2026
5
+
ms.date: 04/14/2026
6
6
ms.custom:
7
7
# Customer intent: "As a cloud solutions architect, I want to deploy Batch workloads using Spot VMs, so that I can reduce costs while managing jobs with flexible completion times and efficient resource allocation."
8
8
---
@@ -11,39 +11,13 @@ ms.custom:
11
11
12
12
Azure Batch offers Spot virtual machines (VMs) to reduce the cost of Batch workloads. Spot VMs make new types of Batch workloads possible by enabling a large amount of compute power to be used for a low cost.
13
13
14
-
Spot VMs take advantage of surplus capacity in Azure. When you specify Spot VMs in your pools, Azure Batch can use this surplus, when available.
14
+
Spot VMs take advantage of surplus capacity in Azure. The amount of surplus capacity that is available varies depending on factors such as VM family, VM size, region, and time of day. When you specify Spot VMs in your pools, Azure Batch can use this surplus, when available.
15
15
16
-
The tradeoff for using Spot VMs is that those VMs might not always be available, or they might get preempted at any time, depending on available capacity. For this reason, Spot VMs are most suitable for batch and asynchronous processing workloads where the job completion time is flexible and the work is distributed across many VMs.
16
+
The tradeoff for using Spot VMs is that these VMs have no SLA and no availability guarantees. Spot VMs can be preempted at any time, including immediately upon VM creation. For this reason, Spot VMs are most suitable for batch and asynchronous processing workloads where the job completion time is flexible and the work is distributed across many VMs.
17
17
18
-
Spot VMs are offered at a reduced price compared with dedicated VMs. To learn more about pricing, see [Batch pricing](https://azure.microsoft.com/pricing/details/batch/).
19
-
20
-
## Differences between Spot and low-priority VMs
21
-
22
-
Batch offers two types of low-cost preemptible VMs:
23
-
24
-
-[Spot VMs](/azure/virtual-machines/spot-vms), a modern Azure-wide offering also available as single-instance VMs or Virtual Machine Scale Sets.
25
-
- Low-priority VMs, a legacy offering only available through Azure Batch.
26
-
27
-
> [!IMPORTANT]
28
-
> Until the low priority to spot VM migration takes place in March 2026, the type of node you get depends on your Batch account's pool allocation mode, which can be set during
29
-
> account creation. Batch accounts that use the **user subscription** pool allocation mode always get Spot VMs. Batch accounts that use the **Batch managed** pool allocation mode
30
-
> always get low-priority VMs. After the low priority migration in March 2026, spot VMs will be allocated regardless of account type. For more information about the migration,
31
-
> see [migrate to Spot VMs in Batch](low-priority-vms-retirement-migration-guide.md).
32
-
33
-
Azure Spot VMs and Batch low-priority VMs are similar but have a few differences in behavior. Until the migration even in March 2026, the differences are:
18
+
If a preemption occurs, the Spot compute node will be evicted and all work that wasn't appropriately checkpointed will be lost. Checkpointing is optional and is up to the Batch end-user to implement. The running Batch task that was interrupted due to preemption will be automatically requeued for execution by a different compute node. A preempted VM may later be restored by the Azure platform, but restoration is only attempted for the first 48 hours after preemption and is not guaranteed to eventually succeed.
|**Available regions**| All regions that support [Spot VMs](/azure/virtual-machines/spot-vms)| All regions except Microsoft Azure operated by 21Vianet |
39
-
|**Customer eligibility**| Not available for some subscription offer types. See more about [Spot limitations](/azure/virtual-machines/spot-vms#limitations). | Available for all Batch customers |
40
-
|**Possible reasons for eviction**| Capacity | Capacity |
41
-
|**Pricing Model**| Variable discounts relative to standard VM prices | Fixed discounts relative to standard VM prices |
42
-
|**Quota model**| Subject to core quotas on your subscription | Subject to core quotas on your Batch account |
43
-
|**Availability SLA**| None | None |
44
-
45
-
> [!WARNING]
46
-
> After the migration in March 2026, Low priority VMs in Batch will be retired and no longer available.
20
+
Spot VMs are offered at a reduced price compared with dedicated VMs. To learn more about pricing, see [Batch pricing](https://azure.microsoft.com/pricing/details/batch/).
47
21
48
22
## Batch support for Spot VMs
49
23
@@ -82,6 +56,16 @@ Keep in mind the following practices when planning your use of Spot VMs:
82
56
83
57
A Batch pool can contain both dedicated and Spot VMs (also referred to as compute nodes). You can set the target number of compute nodes for both dedicated and Spot VMs. The target number of nodes specifies the number of VMs you want to have in the pool.
84
58
59
+
Spot VMs might occasionally be preempted. When preemption happens, tasks that were running on the preempted node VMs are requeued and run again when capacity returns. Batch also performs the following behaviors:
60
+
61
+
- The preempted VMs have their state updated to *Preempted*.
62
+
- The VM is effectively deleted, leading to loss of any data stored locally on the VM.
63
+
- A list nodes operation on the pool still returns the preempted nodes.
64
+
- The pool continually attempts to reach the target number of Spot nodes available. When replacement capacity is found, the nodes keep their IDs, but are reinitialized, going through *Creating* and *Starting* states before they're available for task scheduling.
65
+
- Preemption counts are available as a metric in the Azure portal.
66
+
67
+
### Azure Batch SDK
68
+
85
69
The following example creates a pool using Azure virtual machines, in this case Linux VMs, with a target of 5 dedicated VMs and 20 Spot VMs:
86
70
87
71
```csharp
@@ -116,18 +100,6 @@ Pool nodes have a property to indicate if the node is a dedicated or Spot VM:
116
100
bool?isNodeDedicated=poolNode.IsDedicated;
117
101
```
118
102
119
-
Spot VMs might occasionally be preempted. When preemption happens, tasks that were running on the preempted node VMs are requeued and run again when capacity returns.
120
-
121
-
For Virtual Machine Configuration pools, Batch also performs the following behaviors:
122
-
123
-
- The preempted VMs have their state updated to *Preempted*.
124
-
- The VM is effectively deleted, leading to loss of any data stored locally on the VM.
125
-
- A list nodes operation on the pool still returns the preempted nodes.
126
-
- The pool continually attempts to reach the target number of Spot nodes available. When replacement capacity is found, the nodes keep their IDs, but are reinitialized, going through *Creating* and *Starting* states before they're available for task scheduling.
127
-
- Preemption counts are available as a metric in the Azure portal.
128
-
129
-
## Scale pools containing Spot VMs
130
-
131
103
As with pools solely consisting of dedicated VMs, it's possible to scale a pool containing Spot VMs by calling the `Resize` method or by using autoscale.
132
104
133
105
The pool resize operation takes a second optional parameter that updates the value of `targetLowPriorityNodes`:
@@ -136,12 +108,80 @@ The pool resize operation takes a second optional parameter that updates the val
$pool | Select-Object Id, VmSize, @{Name="SpotNodes";Expression={$_.TargetLowPriorityComputeNodes}}, State
163
+
```
164
+
165
+
### Azure portal
166
+
167
+
1. In the Azure portal, select the Batch account and view an existing pool or create a new pool.
168
+
2. Under **Scale**, select either **Target dedicated nodes** or **Target Spot/low-priority nodes**.
169
+
170
+
:::image type="content" source="media/certificates/low-priority-vms-scale-target-nodes.png" alt-text="Screenshot that shows how to scale target nodes.":::
171
+
172
+
3. For an existing pool, select the pool, and then select **Scale** to update the number of Spot nodes required.
173
+
4. Select **Save**.
174
+
175
+
### Autoscale with Spot VMs
176
+
177
+
Besides setting target VM counts directly, you may optionally define an autoscale formula for your pool. The pool autoscale formula supports Spot VMs as follows:
140
178
141
179
- You can get or set the value of the service-defined variable `$TargetLowPriorityNodes`.
142
180
- You can get the value of the service-defined variable `$CurrentLowPriorityNodes`.
143
181
- You can get the value of the service-defined variable `$PreemptedNodeCount`. This variable returns the number of nodes in the preempted state and allows you to scale up or down the number of dedicated nodes, depending on the number of preempted nodes that are unavailable.
144
182
183
+
For more information, see the [Batch Autoscale Guide](batch-automatic-scaling.md).
184
+
145
185
## Configure jobs and tasks
146
186
147
187
Jobs and tasks may require some extra configuration for Spot nodes:
@@ -166,12 +206,11 @@ To view these metrics in the Azure portal:
166
206
## Limitations
167
207
168
208
- Spot VMs in Batch don't support setting a max price and don't support price-based evictions. They can only be evicted for capacity reasons.
169
-
- Spot VMs are only available for Virtual Machine Configuration pools and not for Cloud Service Configuration pools, which are [deprecated](https://azure.microsoft.com/updates/azure-batch-cloudserviceconfiguration-pools-will-be-retired-on-29-february-2024/).
170
209
- Spot VMs aren't available for some clouds, VM sizes, and subscription offer types. See more about [Spot VM limitations](/azure/virtual-machines/spot-vms#limitations).
171
210
- Currently, [ephemeral OS disks](create-pool-ephemeral-os-disk.md) aren't supported with Spot VMs due to the service-managed eviction policy of *Stop-Deallocate*.
172
211
173
212
## Next steps
174
213
175
214
- Learn about the [Batch service workflow and primary resources](batch-service-workflow-features.md) such as pools, nodes, jobs, and tasks.
176
215
- Learn about the [Batch APIs and tools](batch-apis-tools.md) available for building Batch solutions.
177
-
-Start to plan the move from low-priority VMs to Spot VMs. If you use low-priority VMs with *Cloud Services Configuration* pools (which are [deprecated](https://azure.microsoft.com/updates/azure-batch-cloudserviceconfiguration-pools-will-be-retired-on-29-february-2024)), plan to migrate to [Virtual Machine Configuration pools](nodes-and-pools.md#configurations) instead.
216
+
-For more information about Spot VMs in Azure, including how to view historical pricing and eviction rates, see [Spot Virtual Machines](/azure/virtual-machines/spot-vms).
0 commit comments