Skip to content

Commit ab0aba5

Browse files
committed
Fixes MicrosoftDocs/azure-docs#29449 - Updating C# snippets
1 parent 279f4e0 commit ab0aba5

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

articles/batch/batch-docker-container-workloads.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
title: Container workloads
33
description: Learn how to run and scale apps from container images on Azure Batch. Create a pool of compute nodes that support running container tasks.
44
ms.topic: article
5-
ms.date: 03/02/2020
5+
ms.date: 05/20/2020
66
ms.custom: seodec18
7-
87
---
9-
108
# Run container applications on Azure Batch
119

1210
Azure Batch lets you run and scale large numbers of batch computing jobs on Azure. Batch tasks can run directly on virtual machines (nodes) in a Batch pool, but you can also set up a Batch pool to run tasks in Docker-compatible containers on the nodes. This article shows you how to create a pool of compute nodes that support running container tasks, and then run container tasks on the pool.
@@ -155,32 +153,36 @@ new_pool = batch.models.PoolAddParameter(
155153
The following C# example assumes that you want to prefetch a TensorFlow image from [Docker Hub](https://hub.docker.com). This example includes a start task that runs in the VM host on the pool nodes. You might run a start task in the host, for example, to mount a file server that can be accessed from the containers.
156154

157155
```csharp
158-
159156
ImageReference imageReference = new ImageReference(
160157
publisher: "microsoft-azure-batch",
161158
offer: "ubuntu-server-container",
162159
sku: "16-04-lts",
163160
version: "latest");
164161

162+
ContainerRegistry containerRegistry = new ContainerRegistry(
163+
registryServer: "https://hub.docker.com",
164+
userName: "UserName",
165+
password: "YourPassword"
166+
);
167+
165168
// Specify container configuration, prefetching Docker images
166-
ContainerConfiguration containerConfig = new ContainerConfiguration(
167-
containerImageNames: new List<string> { "tensorflow/tensorflow:latest-gpu" } );
169+
ContainerConfiguration containerConfig = new ContainerConfiguration();
170+
containerConfig.ContainerImageNames = new List<string> { "tensorflow/tensorflow:latest-gpu" };
171+
containerConfig.ContainerRegistries = new List<ContainerRegistry> { containerRegistry };
168172

169173
// VM configuration
170174
VirtualMachineConfiguration virtualMachineConfiguration = new VirtualMachineConfiguration(
171175
imageReference: imageReference,
172-
containerConfiguration: containerConfig,
173176
nodeAgentSkuId: "batch.node.ubuntu 16.04");
174177

175178
// Set a native host command line start task
176-
StartTask startTaskNative = new StartTask( CommandLine: "<native-host-command-line>" );
179+
StartTask startTaskContainer = new StartTask( commandLine: "<native-host-command-line>" );
177180

178181
// Create pool
179182
CloudPool pool = batchClient.PoolOperations.CreatePool(
180183
poolId: poolId,
181-
targetDedicatedComputeNodes: 4,
182184
virtualMachineSize: "Standard_NC6",
183-
virtualMachineConfiguration: virtualMachineConfiguration, startTaskContainer);
185+
virtualMachineConfiguration: virtualMachineConfiguration);
184186
...
185187
```
186188

@@ -191,22 +193,22 @@ You can also prefetch container images by authenticating to a private container
191193

192194
```csharp
193195
// Specify a container registry
194-
ContainerRegistry containerRegistry = new ContainerRegistry (
195-
registryServer: "myContainerRegistry.azurecr.io",
196-
username: "myUserName",
196+
ContainerRegistry containerRegistry = new ContainerRegistry(
197+
registryServer: "myContainerRegistry.azurecr.io",
198+
userName: "myUserName",
197199
password: "myPassword");
198200

199201
// Create container configuration, prefetching Docker images from the container registry
200-
ContainerConfiguration containerConfig = new ContainerConfiguration(
201-
containerImageNames: new List<string> {
202-
"myContainerRegistry.azurecr.io/tensorflow/tensorflow:latest-gpu" },
203-
containerRegistries: new List<ContainerRegistry> { containerRegistry } );
202+
ContainerConfiguration containerConfig = new ContainerConfiguration();
203+
containerConfig.ContainerImageNames = new List<string> {
204+
"myContainerRegistry.azurecr.io/tensorflow/tensorflow:latest-gpu" };
205+
containerConfig.ContainerRegistries = new List<ContainerRegistry> { containerRegistry } );
204206

205207
// VM configuration
206208
VirtualMachineConfiguration virtualMachineConfiguration = new VirtualMachineConfiguration(
207209
imageReference: imageReference,
208-
containerConfiguration: containerConfig,
209210
nodeAgentSkuId: "batch.node.ubuntu 16.04");
211+
virtualMachineConfiguration.ContainerConfiguration = containerConfig;
210212

211213
// Create pool
212214
CloudPool pool = batchClient.PoolOperations.CreatePool(
@@ -281,7 +283,6 @@ The following C# example shows basic container settings for a cloud task:
281283

282284
```csharp
283285
// Simple container task command
284-
285286
string cmdLine = "c:\\app\\myApp.exe";
286287

287288
TaskContainerSettings cmdContainerSettings = new TaskContainerSettings (
@@ -291,11 +292,10 @@ TaskContainerSettings cmdContainerSettings = new TaskContainerSettings (
291292

292293
CloudTask containerTask = new CloudTask (
293294
id: "Task1",
294-
containerSettings: cmdContainerSettings,
295-
commandLine: cmdLine);
295+
commandline: cmdLine);
296+
containerTask.ContainerSettings = cmdContainerSettings;
296297
```
297298

298-
299299
## Next steps
300300

301301
* Also see the [Batch Shipyard](https://github.com/Azure/batch-shipyard) toolkit for easy deployment of container workloads on Azure Batch through [Shipyard recipes](https://github.com/Azure/batch-shipyard/tree/master/recipes).

0 commit comments

Comments
 (0)