Skip to content

Commit 803c877

Browse files
authored
Merge pull request #312751 from wiboris/batchCreatePoolEphemeraOsDiskUpdate
Batch Updating Ephemera OSDisk doc
2 parents 266ed9e + d11a012 commit 803c877

1 file changed

Lines changed: 90 additions & 18 deletions

File tree

articles/batch/create-pool-ephemeral-os-disk.md

Lines changed: 90 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Use ephemeral OS disk nodes for Azure Batch pools
33
description: Learn how and why to create a Batch pool that uses ephemeral OS disk nodes.
44
ms.topic: how-to
5-
ms.date: 03/27/2025
5+
ms.date: 03/06/2026
66
ms.devlang: csharp
77
# Customer intent: "As a cloud architect, I want to configure Azure Batch pools with ephemeral OS disks, so that I can reduce costs and improve application performance for stateless workloads."
88
---
@@ -40,30 +40,102 @@ The following example shows how to create a Batch pool where the nodes use ephem
4040

4141
### Code examples
4242

43-
This code snippet shows how to create a pool with ephemeral OS disks using Azure Batch Python SDK with the Ephemeral OS disk using the temporary disk (cache).
43+
This code snippet shows how to create a pool with ephemeral OS disks using the azure-mgmt-batch Python SDK with the ephemeral OS disk using the temporary disk (cache).
4444

4545
```python
46-
virtual_machine_configuration=batch.models.VirtualMachineConfiguration(
47-
image_reference=image_ref_to_use,
48-
node_agent_sku_id=node_sku_id,
49-
os_disk=batch.models.OSDisk(
50-
ephemeral_os_disk_settings=batch.models.DiffDiskSettings(
51-
placement=batch.models.DiffDiskPlacement.cache_disk
52-
)
53-
)
46+
from azure.identity import DefaultAzureCredential
47+
from azure.mgmt.batch import BatchManagementClient
48+
from azure.mgmt.batch.models import (
49+
BatchAccountPoolData,
50+
DeploymentConfiguration,
51+
VirtualMachineConfiguration,
52+
ImageReference,
53+
OSDisk,
54+
DiffDiskSettings,
55+
DiffDiskPlacement,
5456
)
57+
58+
59+
def create_pool_with_ephemeral_os_disk():
60+
client = BatchManagementClient(
61+
credential=DefaultAzureCredential(),
62+
subscription_id="subscriptionId",
63+
)
64+
65+
pool = client.pool.create(
66+
resource_group_name="resourceGroupName",
67+
account_name="accountName",
68+
pool_name="ephemeralOSDiskPool",
69+
parameters=BatchAccountPoolData(
70+
vm_size="standard_ds1_v2",
71+
deployment_configuration=DeploymentConfiguration(
72+
virtual_machine_configuration=VirtualMachineConfiguration(
73+
image_reference=ImageReference(
74+
publisher="Canonical",
75+
offer="UbuntuServer",
76+
sku="22.04-LTS",
77+
),
78+
node_agent_sku_id="batch.node.ubuntu 22.04",
79+
os_disk=OSDisk(
80+
ephemeral_os_disk_settings=DiffDiskSettings(
81+
placement=DiffDiskPlacement.CACHE_DISK
82+
)
83+
),
84+
)
85+
),
86+
),
87+
)
5588
```
5689

57-
This is the same code snippet but for creating a pool with ephemeral OS disks using the Azure Batch .NET SDK and C#.
90+
This is the same code snippet but for creating a pool with ephemeral OS disks using the Azure.ResourceManager.Batch SDK and C#.
5891

5992
```csharp
60-
VirtualMachineConfiguration virtualMachineConfiguration = new VirtualMachineConfiguration(
61-
imageReference: imageReference,
62-
nodeAgentSkuId: nodeAgentSku
63-
);
64-
virtualMachineConfiguration.OSDisk = new OSDisk();
65-
virtualMachineConfiguration.OSDisk.EphemeralOSDiskSettings = new DiffDiskSettings();
66-
virtualMachineConfiguration.OSDisk.EphemeralOSDiskSettings.Placement = DiffDiskPlacement.CacheDisk;
93+
using Azure;
94+
using Azure.Identity;
95+
using Azure.ResourceManager;
96+
using Azure.ResourceManager.Batch;
97+
using Azure.ResourceManager.Batch.Models;
98+
99+
//...
100+
101+
public async Task SetEphemeralOSDisk()
102+
{
103+
ArmClient client = new ArmClient(new DefaultAzureCredential());
104+
105+
ResourceIdentifier batchAccountResourceId =
106+
BatchAccountResource.CreateResourceIdentifier("subscriptionId", "resourceGroupName", "accountName");
107+
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
108+
109+
BatchAccountPoolCollection poolCollection = batchAccount.GetBatchAccountPools();
110+
111+
BatchAccountPoolData poolData = new BatchAccountPoolData()
112+
{
113+
VmSize = "standard_ds1_v2",
114+
DeploymentConfiguration = new BatchDeploymentConfiguration()
115+
{
116+
VmConfiguration = new BatchVmConfiguration(
117+
imageReference: new BatchImageReference()
118+
{
119+
Publisher = "Canonical",
120+
Offer = "UbuntuServer",
121+
Sku = "22.04-LTS"
122+
},
123+
nodeAgentSkuId: "batch.node.ubuntu 22.04")
124+
{
125+
OSDisk = new BatchOSDisk()
126+
{
127+
EphemeralOSDiskSettings = new DiffDiskSettings()
128+
{
129+
Placement = BatchDiffDiskPlacement.CacheDisk
130+
}
131+
}
132+
}
133+
}
134+
};
135+
136+
ArmOperation<BatchAccountPoolResource> pool = await poolCollection.CreateOrUpdateAsync(
137+
WaitUntil.Completed, "ephemeralOSDiskPool", poolData);
138+
}
67139
```
68140

69141
## Next steps

0 commit comments

Comments
 (0)