@@ -245,8 +245,7 @@ ImageReference imageReference = new ImageReference(
245
245
246
246
ContainerRegistry containerRegistry = new ContainerRegistry (
247
247
registryServer : " https://hub.docker.com" ,
248
- userName : " UserName" ,
249
- password : " YourPassword"
248
+ identityReference : new ComputeNodeIdentityReference () { ResourceId = " /subscriptions/SUB/resourceGroups/RG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name" }
250
249
);
251
250
252
251
// Specify container configuration, prefetching Docker images
@@ -286,10 +285,14 @@ image_ref_to_use = batch.models.ImageReference(
286
285
version = ' latest' )
287
286
288
287
# Specify a container registry
288
+ subscription_id = " yyyy-yyy-yyy-yyy-yyy"
289
+ resource_group_name = " TestRG"
290
+ user_assigned_identity_name = " testUMI"
291
+ resource_id = f " /subscriptions/ { subscription_id} /resourceGroups/ { resource_group_name} /providers/Microsoft.ManagedIdentity/userAssignedIdentities/ { user_assigned_identity_name} "
292
+
289
293
container_registry = batch.models.ContainerRegistry(
290
294
registry_server = " myRegistry.azurecr.io" ,
291
- user_name = " myUsername" ,
292
- password = " myPassword" )
295
+ identity_reference = ComputeNodeIdentityReference(resource_id = resource_id))
293
296
294
297
# Create container configuration, prefetching Docker images from the container registry
295
298
container_conf = batch.models.ContainerConfiguration(
@@ -310,8 +313,8 @@ new_pool = batch.models.PoolAddParameter(
310
313
// Specify a container registry
311
314
ContainerRegistry containerRegistry = new ContainerRegistry (
312
315
registryServer : " myContainerRegistry.azurecr.io" ,
313
- userName : " myUserName " ,
314
- password : " myPassword " );
316
+ identityReference : new ComputeNodeIdentityReference () { ResourceId = " /subscriptions/SUB/resourceGroups/RG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name " }
317
+ );
315
318
316
319
// Create container configuration, prefetching Docker images from the container registry
317
320
ContainerConfiguration containerConfig = new ContainerConfiguration ();
@@ -337,7 +340,7 @@ CloudPool pool = batchClient.PoolOperations.CreatePool(
337
340
### Managed identity support for ACR
338
341
339
342
When you access containers stored in [ Azure Container Registry] ( https://azure.microsoft.com/services/container-registry ) ,
340
- either a username/password or a managed identity can be used to authenticate with the service. To use a managed identity,
343
+ a managed identity can be used to authenticate with the service. To use a managed identity,
341
344
first ensure that the identity has been [ assigned to the pool] ( managed-identity-pools.md ) and that the identity has the
342
345
` AcrPull ` role assigned for the container registry you wish to access. Then, instruct Batch with which identity to use
343
346
when authenticating with ACR.
0 commit comments