Skip to content

Commit 7c55cb0

Browse files
committed
updating code sample
1 parent ea793c2 commit 7c55cb0

1 file changed

Lines changed: 45 additions & 5 deletions

File tree

articles/batch/disk-encryption.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,54 @@ After the pool is created, you can see the disk encryption configuration targets
4646

4747
## Examples
4848

49-
The following examples show how to encrypt the OS and temporary disks on a Batch pool using the Batch .NET SDK, the Batch REST API, and the Azure CLI.
49+
The following examples show how to encrypt the OS and temporary disks on a Batch pool using the Azure.ResourceManager.Batch SDK, the Batch REST API, and the Azure CLI.
5050

51-
### Batch .NET SDK
51+
### Azure.ResourceManager.Batch SDK
5252

5353
```csharp
54-
pool.VirtualMachineConfiguration.DiskEncryptionConfiguration = new DiskEncryptionConfiguration(
55-
targets: new List<DiskEncryptionTarget> { DiskEncryptionTarget.OsDisk, DiskEncryptionTarget.TemporaryDisk }
56-
);
54+
using Azure;
55+
using Azure.Identity;
56+
using Azure.ResourceManager;
57+
using Azure.ResourceManager.Batch;
58+
using Azure.ResourceManager.Batch.Models;
59+
60+
//...
61+
62+
public async Task SetDiskEncryption()
63+
{
64+
ArmClient client = new ArmClient(new DefaultAzureCredential());
65+
66+
ResourceIdentifier batchAccountResourceId =
67+
BatchAccountResource.CreateResourceIdentifier("subscriptionId", "resourceGroupName", "accountName");
68+
BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId);
69+
70+
BatchAccountPoolCollection poolCollection = batchAccount.GetBatchAccountPools();
71+
72+
BatchAccountPoolData poolData = new BatchAccountPoolData()
73+
{
74+
VmSize = "standard_ds1_v2",
75+
DeploymentConfiguration = new BatchDeploymentConfiguration()
76+
{
77+
VmConfiguration = new BatchVmConfiguration(
78+
imageReference: new BatchImageReference()
79+
{
80+
Publisher = "Canonical",
81+
Offer = "UbuntuServer",
82+
Sku = "22.04-LTS"
83+
},
84+
nodeAgentSkuId: "batch.node.ubuntu 22.04")
85+
{
86+
DiskEncryptionConfiguration = new BatchDiskEncryptionConfiguration()
87+
{
88+
Targets = { BatchDiskEncryptionTarget.OSDisk, BatchDiskEncryptionTarget.TemporaryDisk }
89+
}
90+
}
91+
}
92+
};
93+
94+
ArmOperation<BatchAccountPoolResource> pool = await poolCollection.CreateOrUpdateAsync(
95+
WaitUntil.Completed, "diskencryptionPool", poolData);
96+
}
5797
```
5898

5999
### Batch REST API

0 commit comments

Comments
 (0)