Skip to content

Commit 0691dab

Browse files
authored
Update create-pool-availability-zones.md
Updating csharp code
1 parent 1eab5a3 commit 0691dab

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

articles/batch/create-pool-availability-zones.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Create a pool across availability zones
33
description: Learn how to create a Batch pool with zonal policy to help protect against failures.
44
ms.topic: how-to
5-
ms.date: 05/25/2023
5+
ms.date: 08/12/2024
66
ms.devlang: csharp
77
ms.custom:
88
---
@@ -33,10 +33,47 @@ The following examples show how to create a Batch pool across Availability Zones
3333
### Batch Management Client .NET SDK
3434

3535
```csharp
36-
pool.DeploymentConfiguration.VirtualMachineConfiguration.NodePlacementConfiguration = new NodePlacementConfiguration()
36+
var credential = new DefaultAzureCredential();
37+
ArmClient _armClient = new ArmClient(credential);
38+
39+
var batchAccountIdentifier = ResourceIdentifier.Parse("your-batch-account-resource-id");
40+
41+
BatchAccountResource batchAccount = _armClient.GetBatchAccountResource(batchAccountIdentifier);
42+
43+
var poolName = "pool2";
44+
var imageReference = new BatchImageReference()
45+
{
46+
Publisher = "canonical",
47+
Offer = "0001-com-ubuntu-server-jammy",
48+
Sku = "22_04-lts",
49+
Version = "latest"
50+
};
51+
string nodeAgentSku = "batch.node.ubuntu 22.04";
52+
53+
var batchAccountPoolData = new BatchAccountPoolData()
54+
{
55+
VmSize = "Standard_DS1_v2",
56+
DeploymentConfiguration = new BatchDeploymentConfiguration()
3757
{
38-
Policy = NodePlacementPolicyType.Zonal
39-
};
58+
VmConfiguration = new BatchVmConfiguration(imageReference, nodeAgentSku)
59+
{
60+
NodePlacementPolicy = BatchNodePlacementPolicyType.Zonal,
61+
},
62+
},
63+
ScaleSettings = new BatchAccountPoolScaleSettings()
64+
{
65+
FixedScale = new BatchAccountFixedScaleSettings()
66+
{
67+
TargetDedicatedNodes = 5,
68+
ResizeTimeout = TimeSpan.FromMinutes(15),
69+
}
70+
},
71+
72+
};
73+
74+
ArmOperation<BatchAccountPoolResource> armOperation = batchAccount.GetBatchAccountPools().CreateOrUpdate(
75+
WaitUntil.Completed, poolName, batchAccountPoolData);
76+
BatchAccountPoolResource pool = armOperation.Value;
4077

4178
```
4279

0 commit comments

Comments
 (0)