|
2 | 2 | title: Create a pool with disk encryption enabled |
3 | 3 | description: Learn how to use disk encryption configuration to encrypt nodes with a platform-managed key. |
4 | 4 | ms.topic: how-to |
5 | | -ms.date: 07/01/2025 |
| 5 | +ms.date: 03/06/2026 |
6 | 6 | ms.devlang: csharp |
7 | 7 | ms.custom: devx-track-azurecli |
8 | 8 | # Customer intent: "As a cloud administrator, I want to create a Batch pool with disk encryption enabled, so that I can safeguard data on the compute nodes while reducing management overhead." |
@@ -46,14 +46,54 @@ After the pool is created, you can see the disk encryption configuration targets |
46 | 46 |
|
47 | 47 | ## Examples |
48 | 48 |
|
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. |
50 | 50 |
|
51 | | -### Batch .NET SDK |
| 51 | +### Azure.ResourceManager.Batch SDK |
52 | 52 |
|
53 | 53 | ```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 | +} |
57 | 97 | ``` |
58 | 98 |
|
59 | 99 | ### Batch REST API |
|
0 commit comments