|
2 | 2 | title: 'Quickstart: Use .NET to create a pool and run a job'
|
3 | 3 | description: Follow this quickstart to run a C# app that uses the Batch .NET client library to create and run Batch pools, nodes, jobs, and tasks.
|
4 | 4 | ms.topic: quickstart
|
5 |
| -ms.date: 04/20/2023 |
| 5 | +ms.date: 04/28/2023 |
6 | 6 | ms.devlang: csharp
|
7 | 7 | ms.custom: mvc, devx-track-csharp, mode-api
|
8 | 8 | ---
|
@@ -118,36 +118,36 @@ Review the code to understand the steps in the [Azure Batch .NET Quickstart](htt
|
118 | 118 |
|
119 | 119 | ### Create service clients and upload resource files
|
120 | 120 |
|
121 |
| -1. To interact with the storage account, the app uses the Azure Storage Client Library for .NET to create a reference to the account with [CloudStorageAccount](/dotnet/api/microsoft.azure.storage.cloudstorageaccount), and from that creates a [CloudBlobClient](/dotnet/api/microsoft.azure.storage.blob.cloudblobclient). |
| 121 | +1. To interact with the storage account, the app uses the Azure Storage Blobs client library for .NET to create a [BlobServiceClient](/dotnet/api/azure.storage.blobs.blobserviceclient). |
122 | 122 |
|
123 | 123 | ```csharp
|
124 |
| - CloudBlobClient blobClient = CreateCloudBlobClient(StorageAccountName, StorageAccountKey); |
| 124 | + var blobServiceClient = GetBlobServiceClient(StorageAccountName, StorageAccountKey); |
125 | 125 | ```
|
126 | 126 |
|
127 |
| -1. The app uses the `blobClient` reference to create a container in the storage account and upload data files to the container. The files in storage are defined as Batch [ResourceFile](/dotnet/api/microsoft.azure.batch.resourcefile) objects that Batch can later download to the compute nodes. |
| 127 | +1. The app uses the `blobServiceClient` reference to create a container in the storage account and upload data files to the container. The files in storage are defined as Batch [ResourceFile](/dotnet/api/microsoft.azure.batch.resourcefile) objects that Batch can later download to the compute nodes. |
128 | 128 |
|
129 | 129 | ```csharp
|
130 |
| - List<string> inputFilePaths = new List<string> |
| 130 | + List<string> inputFilePaths = new() |
131 | 131 | {
|
132 | 132 | "taskdata0.txt",
|
133 | 133 | "taskdata1.txt",
|
134 | 134 | "taskdata2.txt"
|
135 | 135 | };
|
136 | 136 |
|
137 |
| - List<ResourceFile> inputFiles = new List<ResourceFile>(); |
| 137 | + var inputFiles = new List<ResourceFile>(); |
138 | 138 |
|
139 |
| - foreach (string filePath in inputFilePaths) |
| 139 | + foreach (var filePath in inputFilePaths) |
140 | 140 | {
|
141 |
| - inputFiles.Add(UploadFileToContainer(blobClient, inputContainerName, filePath)); |
| 141 | + inputFiles.Add(UploadFileToContainer(containerClient, inputContainerName, filePath)); |
142 | 142 | }
|
143 | 143 | ```
|
144 | 144 |
|
145 | 145 | 1. The app creates a [BatchClient](/dotnet/api/microsoft.azure.batch.batchclient) object to create and manage Batch pools, jobs, and tasks. The Batch client uses shared key authentication. Batch also supports Azure Active Directory (Azure AD) authentication.
|
146 | 146 |
|
147 | 147 | ```csharp
|
148 |
| - BatchSharedKeyCredentials cred = new BatchSharedKeyCredentials(BatchAccountUrl, BatchAccountName, BatchAccountKey); |
| 148 | + var cred = new BatchSharedKeyCredentials(BatchAccountUrl, BatchAccountName, BatchAccountKey); |
149 | 149 |
|
150 |
| - using (BatchClient batchClient = BatchClient.Open(cred)) |
| 150 | + using BatchClient batchClient = BatchClient.Open(cred); |
151 | 151 | ...
|
152 | 152 | ```
|
153 | 153 |
|
@@ -224,8 +224,10 @@ for (int i = 0; i < inputFiles.Count; i++)
|
224 | 224 | string inputFilename = inputFiles[i].FilePath;
|
225 | 225 | string taskCommandLine = String.Format("cmd /c type {0}", inputFilename);
|
226 | 226 |
|
227 |
| - CloudTask task = new CloudTask(taskId, taskCommandLine); |
228 |
| - task.ResourceFiles = new List<ResourceFile> { inputFiles[i] }; |
| 227 | + var task = new CloudTask(taskId, taskCommandLine) |
| 228 | + { |
| 229 | + ResourceFiles = new List<ResourceFile> { inputFiles[i] } |
| 230 | + }; |
229 | 231 | tasks.Add(task);
|
230 | 232 | }
|
231 | 233 |
|
|
0 commit comments