Skip to content

Commit 78ff196

Browse files
committed
code changes
1 parent 7328d24 commit 78ff196

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

articles/batch/quick-run-dotnet.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 'Quickstart: Use .NET to create a pool and run a job'
33
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.
44
ms.topic: quickstart
5-
ms.date: 04/20/2023
5+
ms.date: 04/28/2023
66
ms.devlang: csharp
77
ms.custom: mvc, devx-track-csharp, mode-api
88
---
@@ -118,36 +118,36 @@ Review the code to understand the steps in the [Azure Batch .NET Quickstart](htt
118118
119119
### Create service clients and upload resource files
120120

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).
122122

123123
```csharp
124-
CloudBlobClient blobClient = CreateCloudBlobClient(StorageAccountName, StorageAccountKey);
124+
var blobServiceClient = GetBlobServiceClient(StorageAccountName, StorageAccountKey);
125125
```
126126

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.
128128

129129
```csharp
130-
List<string> inputFilePaths = new List<string>
130+
List<string> inputFilePaths = new()
131131
{
132132
"taskdata0.txt",
133133
"taskdata1.txt",
134134
"taskdata2.txt"
135135
};
136136

137-
List<ResourceFile> inputFiles = new List<ResourceFile>();
137+
var inputFiles = new List<ResourceFile>();
138138

139-
foreach (string filePath in inputFilePaths)
139+
foreach (var filePath in inputFilePaths)
140140
{
141-
inputFiles.Add(UploadFileToContainer(blobClient, inputContainerName, filePath));
141+
inputFiles.Add(UploadFileToContainer(containerClient, inputContainerName, filePath));
142142
}
143143
```
144144

145145
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.
146146

147147
```csharp
148-
BatchSharedKeyCredentials cred = new BatchSharedKeyCredentials(BatchAccountUrl, BatchAccountName, BatchAccountKey);
148+
var cred = new BatchSharedKeyCredentials(BatchAccountUrl, BatchAccountName, BatchAccountKey);
149149

150-
using (BatchClient batchClient = BatchClient.Open(cred))
150+
using BatchClient batchClient = BatchClient.Open(cred);
151151
...
152152
```
153153

@@ -224,8 +224,10 @@ for (int i = 0; i < inputFiles.Count; i++)
224224
string inputFilename = inputFiles[i].FilePath;
225225
string taskCommandLine = String.Format("cmd /c type {0}", inputFilename);
226226

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+
};
229231
tasks.Add(task);
230232
}
231233

0 commit comments

Comments
 (0)