Skip to content

Commit 6508972

Browse files
committed
Freshness pass
1 parent daf3138 commit 6508972

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed
-108 KB
Loading
15.8 KB
Loading

articles/batch/tutorial-parallel-dotnet.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: Tutorial - Run a parallel workload using the .NET API
3-
description: Tutorial - Transcode media files in parallel with ffmpeg in Azure Batch using the Batch .NET client library
2+
title: "Tutorial: Run a parallel workload using the .NET API"
3+
description: Learn how to transcode media files in parallel with ffmpeg in Azure Batch using the Batch .NET client library.
44
ms.devlang: csharp
55
ms.topic: tutorial
6-
ms.date: 06/22/2022
6+
ms.date: 04/18/2023
77
ms.custom: "mvc, devx-track-csharp"
88
---
99

@@ -26,25 +26,27 @@ In this tutorial, you convert MP4 media files in parallel to MP3 format using th
2626

2727
## Prerequisites
2828

29-
* [Visual Studio 2017 or later](https://www.visualstudio.com/vs), or [.NET Core 2.1 SDK](https://dotnet.microsoft.com/download/dotnet/2.1) for Linux, macOS, or Windows.
29+
* [Visual Studio 2017 or later](https://www.visualstudio.com/vs), or [.NET Core SDK](https://dotnet.microsoft.com/download/dotnet) for Linux, macOS, or Windows.
3030

31-
* A Batch account and a linked Azure Storage account. To create these accounts, see the Batch quickstarts using the [Azure portal](quick-create-portal.md) or [Azure CLI](quick-create-cli.md).
31+
* A Batch account and a linked Azure Storage account. To create these accounts, see the Batch quickstart guides for the [Azure portal](quick-create-portal.md) or [Azure CLI](quick-create-cli.md).
3232

33-
* Download the appropriate version of ffmpeg for your use case to your local computer. This tutorial and the related sample app use the [Windows 64-bit version of ffmpeg 4.3.1](https://github.com/GyanD/codexffmpeg/releases/tag/4.3.1-2020-11-08). For this tutorial, you only need the zip file. You do not need to unzip the file or install it locally.
33+
* Download the appropriate version of ffmpeg for your use case to your local computer. This tutorial and the related sample app use the [Windows 64-bit full-build version of ffmpeg 4.3.1](https://github.com/GyanD/codexffmpeg/releases/tag/4.3.1-2020-11-08). For this tutorial, you only need the zip file. You do not need to unzip the file or install it locally.
3434

3535
## Sign in to Azure
3636

37-
Sign in to the Azure portal at [https://portal.azure.com](https://portal.azure.com).
37+
Sign in to [the Azure portal](https://portal.azure.com).
3838

3939
## Add an application package
4040

4141
Use the Azure portal to add ffmpeg to your Batch account as an [application package](batch-application-packages.md). Application packages help you manage task applications and their deployment to the compute nodes in your pool.
4242

43-
1. In the Azure portal, click **More services** > **Batch accounts**, and click the name of your Batch account.
44-
3. Click **Applications** > **Add**.
45-
4. For **Application id** enter *ffmpeg*, and a package version of *4.3.1*. Select the ffmpeg zip file you downloaded previously, and then click **OK**. The ffmpeg application package is added to your Batch account.
43+
1. In the Azure portal, click **More services** > **Batch accounts**, and select the name of your Batch account.
44+
1. Click **Applications** > **Add**.
45+
:::image type="content" source="./media/tutorial-parallel-dotnet/add-application.png" alt-text="Screenshot of the Applications section of the batch account.":::
4646

47-
![Add application package](./media/tutorial-parallel-dotnet/add-application.png)
47+
1. Enter *ffmpeg* in the **Application Id** field, and a package version of *4.3.1* in the **Version** field. Select the ffmpeg zip file that you downloaded, and then select **OK**. The ffmpeg application package is added to your Batch account.
48+
49+
:::image type="content" source="./media/tutorial-parallel-dotnet/new-batch-application.png" alt-text="Screenshot of the ID and version fields in the Add application section.":::
4850

4951
[!INCLUDE [batch-common-credentials](../../includes/batch-common-credentials.md)]
5052

@@ -58,18 +60,18 @@ Use the Azure portal to add ffmpeg to your Batch account as an [application pack
5860
git clone https://github.com/Azure-Samples/batch-dotnet-ffmpeg-tutorial.git
5961
```
6062

61-
Navigate to the directory that contains the Visual Studio solution file `BatchDotNetFfmpegTutorial.sln`.
63+
Navigate to the directory that contains the Visual Studio solution file *BatchDotNetFfmpegTutorial.sln*.
6264

63-
Open the solution file in Visual Studio, and update the credential strings in `Program.cs` with the values you obtained for your accounts. For example:
65+
Open the solution file in Visual Studio, and update the credential strings in *Program.cs* with the values you obtained for your accounts. For example:
6466

6567
```csharp
6668
// Batch account credentials
67-
private const string BatchAccountName = "mybatchaccount";
69+
private const string BatchAccountName = "yourbatchaccount";
6870
private const string BatchAccountKey = "xxxxxxxxxxxxxxxxE+yXrRvJAqT9BlXwwo1CwF+SwAYOxxxxxxxxxxxxxxxx43pXi/gdiATkvbpLRl3x14pcEQ==";
69-
private const string BatchAccountUrl = "https://mybatchaccount.mybatchregion.batch.azure.com";
71+
private const string BatchAccountUrl = "https://yourbatchaccount.yourbatchregion.batch.azure.com";
7072

7173
// Storage account credentials
72-
private const string StorageAccountName = "mystorageaccount";
74+
private const string StorageAccountName = "yourstorageaccount";
7375
private const string StorageAccountKey = "xxxxxxxxxxxxxxxxy4/xxxxxxxxxxxxxxxxfwpbIC5aAWA8wDu+AFXZB827Mt9lybZB1nUcQbQiUrkPtilK5BQ==";
7476
```
7577

@@ -86,7 +88,7 @@ const string appPackageVersion = "4.3.1";
8688

8789
Build and run the application in Visual Studio, or at the command line with the `dotnet build` and `dotnet run` commands. After running the application, review the code to learn what each part of the application does. For example, in Visual Studio:
8890

89-
* Right-click the solution in Solution Explorer and click **Build Solution**.
91+
* Right-click the solution in Solution Explorer and select **Build Solution**.
9092

9193
* Confirm the restoration of any NuGet packages, if you're prompted. If you need to download missing packages, ensure the [NuGet Package Manager](https://docs.nuget.org/consume/installing-nuget) is installed.
9294

@@ -113,19 +115,19 @@ Sample end: 11/19/2018 3:29:36 PM
113115
Elapsed time: 00:09:14.3418742
114116
```
115117

116-
Go to your Batch account in the Azure portal to monitor the pool, compute nodes, job, and tasks. For example, to see a heat map of the compute nodes in your pool, click **Pools** > *WinFFmpegPool*.
118+
Go to your Batch account in the Azure portal to monitor the pool, compute nodes, job, and tasks. For example, to see a heat map of the compute nodes in your pool, click **Pools** > **WinFFmpegPool**.
117119

118120
When tasks are running, the heat map is similar to the following:
119121

120-
![Pool heat map](./media/tutorial-parallel-dotnet/pool.png)
122+
:::image type="content" source="./media/tutorial-parallel-dotnet/pool.png" alt-text="Screenshot of the pool heat map in the Azure portal.":::
121123

122-
Typical execution time is approximately **10 minutes** when you run the application in its default configuration. Pool creation takes the most time.
124+
Typical execution time is approximately *10 minutes* when you run the application in its default configuration. Pool creation takes the most time.
123125

124126
[!INCLUDE [batch-common-tutorial-download](../../includes/batch-common-tutorial-download.md)]
125127

126128
## Review the code
127129

128-
The following sections break down the sample application into the steps that it performs to process a workload in the Batch service. Refer to the file `Program.cs` in the solution while you read the rest of this article, since not every line of code in the sample is discussed.
130+
The following sections break down the sample application into the steps that it performs to process a workload in the Batch service. Refer to the file *Program.cs* in the solution while you read the rest of this article, since not every line of code in the sample is discussed.
129131

130132
### Authenticate Blob and Batch clients
131133

@@ -160,12 +162,12 @@ CreateContainerIfNotExistAsync(blobClient, inputContainerName);
160162
CreateContainerIfNotExistAsync(blobClient, outputContainerName);
161163
```
162164

163-
Then, files are uploaded to the input container from the local `InputFiles` folder. The files in storage are defined as Batch [ResourceFile](/dotnet/api/microsoft.azure.batch.resourcefile) objects that Batch can later download to compute nodes.
165+
Then, files are uploaded to the input container from the local *InputFiles* folder. The files in storage are defined as Batch [ResourceFile](/dotnet/api/microsoft.azure.batch.resourcefile) objects that Batch can later download to compute nodes.
164166

165-
Two methods in `Program.cs` are involved in uploading the files:
167+
Two methods in *Program.cs* are involved in uploading the files:
166168

167-
* `UploadFilesToContainerAsync`: Returns a collection of ResourceFile objects and internally calls `UploadResourceFileToContainerAsync` to upload each file that is passed in the `inputFilePaths` parameter.
168-
* `UploadResourceFileToContainerAsync`: Uploads each file as a blob to the input container. After uploading the file, it obtains a shared access signature (SAS) for the blob and returns a ResourceFile object to represent it.
169+
* `UploadFilesToContainerAsync`: Returns a collection of `ResourceFile` objects and internally calls `UploadResourceFileToContainerAsync` to upload each file that is passed in the `inputFilePaths` parameter.
170+
* `UploadResourceFileToContainerAsync`: Uploads each file as a blob to the input container. After uploading the file, it obtains a shared access signature (SAS) for the blob and returns a `ResourceFile` object to represent it.
169171

170172
```csharp
171173
string inputPath = Path.Combine(Environment.CurrentDirectory, "InputFiles");
@@ -188,7 +190,7 @@ Next, the sample creates a pool of compute nodes in the Batch account with a cal
188190
The number of nodes and VM size are set using defined constants. Batch supports dedicated nodes and [Spot nodes](batch-spot-vms.md), and you can use either or both in your pools. Dedicated nodes are reserved for your pool. Spot nodes are offered at a reduced price from surplus VM capacity in Azure. Spot nodes become unavailable if Azure does not have enough capacity. The sample by default creates a pool containing only 5 Spot nodes in size *Standard_A1_v2*.
189191

190192
>[!Note]
191-
>Be sure you check your node quotas. See [Batch service quotas and limits](batch-quota-limit.md#increase-a-quota) for instructions on how to create a quota request."
193+
>Be sure you check your node quotas. See [Batch service quotas and limits](batch-quota-limit.md#increase-a-quota) for instructions on how to create a quota request.
192194
193195
The ffmpeg application is deployed to the compute nodes by adding an [ApplicationPackageReference](/dotnet/api/microsoft.azure.batch.applicationpackagereference) to the pool configuration.
194196

@@ -244,7 +246,7 @@ The sample creates an [OutputFile](/dotnet/api/microsoft.azure.batch.outputfile)
244246

245247
Then, the sample adds tasks to the job with the [AddTaskAsync](/dotnet/api/microsoft.azure.batch.joboperations.addtaskasync) method, which queues them to run on the compute nodes.
246248

247-
Replace the executable's file path with the name of the version that you downloaded. This sample code uses the example `ffmpeg-4.3.1-2020-09-21-full_build`.
249+
Replace the executable's file path with the name of the version that you downloaded. This sample code uses the example `ffmpeg-4.3.1-2020-11-08-full_build`.
248250

249251
```csharp
250252
// Create a collection to hold the tasks added to the job.
@@ -325,7 +327,4 @@ In this tutorial, you learned how to:
325327
> * Monitor task execution
326328
> * Retrieve output files
327329
328-
For more examples of using the .NET API to schedule and process Batch workloads, see the samples on GitHub.
329-
330-
> [!div class="nextstepaction"]
331-
> [Batch C# samples](https://github.com/Azure-Samples/azure-batch-samples/tree/master/CSharp)
330+
For more examples of using the .NET API to schedule and process Batch workloads, see the [Batch C# samples on GitHub](https://github.com/Azure-Samples/azure-batch-samples/tree/master/CSharp).

0 commit comments

Comments
 (0)