Skip to content

Commit 04162c0

Browse files
authored
Update batch-customer-managed-key.md
Updating code for Azure.ResourceManager.Batch
1 parent 9c91f2d commit 04162c0

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

articles/batch/batch-customer-managed-key.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,33 @@ As an example using the Batch management .NET client, you can create a Batch acc
136136
and customer-managed keys.
137137

138138
```c#
139-
EncryptionProperties encryptionProperties = new EncryptionProperties()
139+
string subscriptionId = "Your SubscriptionID";
140+
string resourceGroupName = "Your ResourceGroup name";
141+
142+
var credential = new DefaultAzureCredential();
143+
ArmClient _armClient = new ArmClient(credential);
144+
145+
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
146+
ResourceGroupResource resourceGroupResource = _armClient.GetResourceGroupResource(resourceGroupResourceId);
147+
148+
var data = new BatchAccountCreateOrUpdateContent(AzureLocation.EastUS)
140149
{
141-
KeySource = KeySource.MicrosoftKeyVault,
142-
KeyVaultProperties = new KeyVaultProperties()
150+
Encryption = new BatchAccountEncryptionConfiguration()
143151
{
144-
KeyIdentifier = "Your Key Azure Resource Manager Resource ID"
145-
}
146-
};
152+
KeySource = BatchAccountKeySource.MicrosoftKeyVault,
153+
KeyIdentifier = new Uri("Your Key Azure Resource Manager Resource ID"),
154+
},
147155

148-
BatchAccountIdentity identity = new BatchAccountIdentity()
149-
{
150-
Type = ResourceIdentityType.UserAssigned,
151-
UserAssignedIdentities = new Dictionary<string, BatchAccountIdentityUserAssignedIdentitiesValue>
156+
Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.UserAssigned)
152157
{
153-
["Your Identity Azure Resource Manager ResourceId"] = new BatchAccountIdentityUserAssignedIdentitiesValue()
158+
UserAssignedIdentities = {
159+
[new ResourceIdentifier("Your Identity Azure Resource Manager ResourceId")] = new UserAssignedIdentity(),
160+
},
154161
}
155162
};
156-
var parameters = new BatchAccountCreateParameters(TestConfiguration.ManagementRegion, encryption:encryptionProperties, identity: identity);
157163

158-
var account = await batchManagementClient.Account.CreateAsync("MyResourceGroup",
159-
"mynewaccount", parameters);
164+
var lro = resourceGroupResource.GetBatchAccounts().CreateOrUpdate(WaitUntil.Completed, "Your BatchAccount name", data);
165+
BatchAccountResource batchAccount = lro.Value;
160166
```
161167

162168
## Update the customer-managed key version

0 commit comments

Comments
 (0)