Skip to content

Commit 1295212

Browse files
Merge pull request #236351 from v-thepet/batch10
Freshness Pass for User Story: 79612 (.NET quickstart changes to reflect code changes)
2 parents 5deaa42 + b8664f5 commit 1295212

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

articles/batch/quick-run-dotnet.md

Lines changed: 18 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,40 @@ 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 sharedKeyCredential = new StorageSharedKeyCredential(storageAccountName, storageAccountKey);
125+
string blobUri = "https://" + storageAccountName + ".blob.core.windows.net";
126+
127+
var blobServiceClient = new BlobServiceClient(new Uri(blobUri), sharedKeyCredential);
128+
return blobServiceClient;
125129
```
126130

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.
131+
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.
128132

129133
```csharp
130-
List<string> inputFilePaths = new List<string>
134+
List<string> inputFilePaths = new()
131135
{
132136
"taskdata0.txt",
133137
"taskdata1.txt",
134138
"taskdata2.txt"
135139
};
136140

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

139-
foreach (string filePath in inputFilePaths)
143+
foreach (var filePath in inputFilePaths)
140144
{
141-
inputFiles.Add(UploadFileToContainer(blobClient, inputContainerName, filePath));
145+
inputFiles.Add(UploadFileToContainer(containerClient, inputContainerName, filePath));
142146
}
143147
```
144148

145149
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.
146150

147151
```csharp
148-
BatchSharedKeyCredentials cred = new BatchSharedKeyCredentials(BatchAccountUrl, BatchAccountName, BatchAccountKey);
152+
var cred = new BatchSharedKeyCredentials(BatchAccountUrl, BatchAccountName, BatchAccountKey);
149153

150-
using (BatchClient batchClient = BatchClient.Open(cred))
154+
using BatchClient batchClient = BatchClient.Open(cred);
151155
...
152156
```
153157

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

227-
CloudTask task = new CloudTask(taskId, taskCommandLine);
228-
task.ResourceFiles = new List<ResourceFile> { inputFiles[i] };
231+
var task = new CloudTask(taskId, taskCommandLine)
232+
{
233+
ResourceFiles = new List<ResourceFile> { inputFiles[i] }
234+
};
229235
tasks.Add(task);
230236
}
231237

0 commit comments

Comments
 (0)