Skip to content

Commit 9c91f2d

Browse files
authored
Update managed-identity-pools.md
Updating the code sample to use the Azure.ResourceManager.Batch library
1 parent 1e73943 commit 9c91f2d

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

articles/batch/managed-identity-pools.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,43 +69,41 @@ To create a Batch pool with a user-assigned managed identity through the Azure p
6969
To create a Batch pool with a user-assigned managed identity with the [Batch .NET management library](/dotnet/api/overview/azure/batch#management-library), use the following example code:
7070

7171
```csharp
72-
var poolParameters = new Pool(name: "yourPoolName")
72+
var credential = new DefaultAzureCredential();
73+
ArmClient _armClient = new ArmClient(credential);
74+
75+
var batchAccountIdentifier = ResourceIdentifier.Parse("your-batch-account-resource-id");
76+
BatchAccountResource batchAccount = _armClient.GetBatchAccountResource(batchAccountIdentifier);
77+
78+
var poolName = "HelloWorldPool";
79+
var imageReference = new BatchImageReference()
80+
{
81+
Publisher = "canonical",
82+
Offer = "0001-com-ubuntu-server-jammy",
83+
Sku = "22_04-lts",
84+
Version = "latest"
85+
};
86+
string nodeAgentSku = "batch.node.ubuntu 22.04";
87+
88+
var batchAccountPoolData = new BatchAccountPoolData()
89+
{
90+
VmSize = "Standard_DS1_v2",
91+
DeploymentConfiguration = new BatchDeploymentConfiguration()
7392
{
74-
VmSize = "standard_d2_v3",
75-
ScaleSettings = new ScaleSettings
76-
{
77-
FixedScale = new FixedScaleSettings
78-
{
79-
TargetDedicatedNodes = 1
80-
}
81-
},
82-
DeploymentConfiguration = new DeploymentConfiguration
83-
{
84-
VirtualMachineConfiguration = new VirtualMachineConfiguration(
85-
new ImageReference(
86-
"Canonical",
87-
"0001-com-ubuntu-server-jammy",
88-
"22_04-lts",
89-
"latest"),
90-
"batch.node.ubuntu 22.04")
91-
},
92-
Identity = new BatchPoolIdentity
93+
VmConfiguration = new BatchVmConfiguration(imageReference, nodeAgentSku)
94+
},
95+
ScaleSettings = new BatchAccountPoolScaleSettings()
96+
{
97+
FixedScale = new BatchAccountFixedScaleSettings()
9398
{
94-
Type = PoolIdentityType.UserAssigned,
95-
UserAssignedIdentities = new Dictionary<string, UserAssignedIdentities>
96-
{
97-
["Your Identity Resource Id"] =
98-
new UserAssignedIdentities()
99-
}
99+
TargetDedicatedNodes = 1
100100
}
101-
};
102-
103-
var pool = await managementClient.Pool.CreateWithHttpMessagesAsync(
104-
poolName:"yourPoolName",
105-
resourceGroupName: "yourResourceGroupName",
106-
accountName: "yourAccountName",
107-
parameters: poolParameters,
108-
cancellationToken: default(CancellationToken)).ConfigureAwait(false);
101+
}
102+
};
103+
104+
ArmOperation<BatchAccountPoolResource> armOperation = batchAccount.GetBatchAccountPools().CreateOrUpdate(
105+
WaitUntil.Completed, poolName, batchAccountPoolData);
106+
BatchAccountPoolResource pool = armOperation.Value;
109107
```
110108

111109
## Use user-assigned managed identities in Batch nodes

0 commit comments

Comments
 (0)