You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One way to persist task data is to use the [Azure Batch File Conventions library for .NET][nuget_package]. The File Conventions library simplifies the process of storing task output data to Azure Storage and retrieving it. You can use the File Conventions library in both task and client code — in task code for persisting files, and in client code to list and retrieve them. Your task code can also use the library to retrieve the output of upstream tasks, such as in a [task dependencies](batch-task-dependencies.md) scenario.
25
+
One way to persist task data is to use the [Azure Batch File Conventions library for .NET][nuget_package]. The File Conventions library simplifies the process of storing task output data to Azure Storage and retrieving it. You can use the File Conventions library in both task and client code — in task code for persisting files, and in client code to list and retrieve them. Your task code can also use the library to retrieve the output of upstream tasks, such as in a [task dependencies](batch-task-dependencies.md) scenario.
26
26
27
27
To retrieve output files with the File Conventions library, you can locate the files for a given job or task by listing them by ID and purpose. You don't need to know the names or locations of the files. For example, you can use the File Conventions library to list all intermediate files for a given task, or get a preview file for a given job.
28
28
29
29
> [!TIP]
30
30
> Starting with version 2017-05-01, the Batch service API supports persisting output data to Azure Storage for tasks and job manager tasks that run on pools created with the virtual machine configuration. The Batch service API provides a simple way to persist output from within the code that creates a task and serves as an alternative to the File Conventions library. You can modify your Batch client applications to persist output without needing to update the application that your task is running. For more information, see [Persist task data to Azure Storage with the Batch service API](batch-task-output-files.md).
31
-
>
32
-
>
33
31
34
32
## When do I use the File Conventions library to persist task output?
35
33
@@ -38,27 +36,27 @@ Azure Batch provides more than one way to persist task output. The File Conventi
38
36
- You can easily modify the code for the application that your task is running to persist files using the File Conventions library.
39
37
- You want to stream data to Azure Storage while the task is still running.
40
38
- You want to persist data from pools created with either the cloud service configuration or the virtual machine configuration.
41
-
- Your client application or other tasks in the job needs to locate and download task output files by ID or by purpose.
39
+
- Your client application or other tasks in the job needs to locate and download task output files by ID or by purpose.
42
40
- You want to view task output in the Azure portal.
43
41
44
-
If your scenario differs from those listed above, you may need to consider a different approach. For more information on other options for persisting task output, see [Persist job and task output to Azure Storage](batch-task-output.md).
42
+
If your scenario differs from those listed above, you may need to consider a different approach. For more information on other options for persisting task output, see [Persist job and task output to Azure Storage](batch-task-output.md).
45
43
46
44
## What is the Batch File Conventions standard?
47
45
48
46
The [Batch File Conventions standard](https://github.com/Azure/azure-sdk-for-net/tree/psSdkJson6/src/SDKs/Batch/Support/FileConventions#conventions) provides a naming scheme for the destination containers and blob paths to which your output files are written. Files persisted to Azure Storage that adhere to the File Conventions standard are automatically available for viewing in the Azure portal. The portal is aware of the naming convention and so can display files that adhere to it.
49
47
50
-
The File Conventions library for .NET automatically names your storage containers and task output files according to the File Conventions standard. The File Conventions library also provides methods to query output files in Azure Storage according to job ID, task ID, or purpose.
48
+
The File Conventions library for .NET automatically names your storage containers and task output files according to the File Conventions standard. The File Conventions library also provides methods to query output files in Azure Storage according to job ID, task ID, or purpose.
51
49
52
-
If you are developing with a language other than .NET, you can implement the File Conventions standard yourself in your application. For more information, see [About the Batch File Conventions standard](batch-task-output.md#about-the-batch-file-conventions-standard).
50
+
If you are developing with a language other than .NET, you can implement the File Conventions standard yourself in your application. For more information, see [Implement the Batch File Conventions standard](batch-task-output.md#implement-the-batch-file-conventions-standard).
53
51
54
52
## Link an Azure Storage account to your Batch account
55
53
56
54
To persist output data to Azure Storage using the File Conventions library, you must first link an Azure Storage account to your Batch account. If you haven't done so already, link a Storage account to your Batch account by using the [Azure portal](https://portal.azure.com):
57
55
58
-
1. Navigate to your Batch account in the Azure portal.
59
-
2. Under **Settings**, select **Storage Account**.
60
-
3. If you do not already have a Storage account associated with your Batch account, click **Storage Account (None)**.
61
-
4. Select a Storage account from the list for your subscription. For best performance, use an Azure Storage account that is in the same region as the Batch account where your tasks are running.
56
+
1. Navigate to your Batch account in the Azure portal.
57
+
1. Under **Settings**, select **Storage Account**.
58
+
1. If you do not already have a Storage account associated with your Batch account, click **Storage Account (None)**.
59
+
1. Select a Storage account from the list for your subscription. For best performance, use an Azure Storage account that is in the same region as the Batch account where your tasks are running.
62
60
63
61
## Persist output data
64
62
@@ -68,12 +66,10 @@ For more information about working with containers and blobs in Azure Storage, s
68
66
69
67
> [!WARNING]
70
68
> All job and task outputs persisted with the File Conventions library are stored in the same container. If a large number of tasks try to persist files at the same time, [storage throttling limits](../storage/common/storage-performance-checklist.md#blobs) may be enforced.
71
-
>
72
-
>
73
69
74
70
### Create storage container
75
71
76
-
To persist task output to Azure Storage, first create a container by calling [CloudJob][net_cloudjob].[PrepareOutputStorageAsync][net_prepareoutputasync]. This extension method takes a [CloudStorageAccount][net_cloudstorageaccount] object as a parameter. It creates a container named according to the File Conventions standard,so that its contents are discoverable by the Azure portal and the retrieval methods discussed later in the article.
72
+
To persist task output to Azure Storage, first create a container by calling [CloudJob][net_cloudjob].[PrepareOutputStorageAsync][net_prepareoutputasync]. This extension method takes a [CloudStorageAccount][net_cloudstorageaccount] object as a parameter. It creates a container named according to the File Conventions standard,so that its contents are discoverable by the Azure portal and the retrieval methods discussed later in the article.
77
73
78
74
You typically place the code to create a container in your client application — the application that creates your pools, jobs, and tasks.
79
75
@@ -116,8 +112,6 @@ These output types allow you to specify which type of outputs to list when you l
116
112
117
113
> [!TIP]
118
114
> The output kind also determines where in the Azure portal a particular file appears: *TaskOutput*-categorized files appear under **Task output files**, and *TaskLog* files appear under **Task logs**.
119
-
>
120
-
>
121
115
122
116
### Store job outputs
123
117
@@ -170,8 +164,6 @@ The node agent is a program that runs on each node in the pool and provides the
170
164
171
165
> [!NOTE]
172
166
> When you enable file tracking with **SaveTrackedAsync**, only *appends* to the tracked file are persisted to Azure Storage. Use this method only for tracking non-rotating log files or other files that are written to with append operations to the end of the file.
173
-
>
174
-
>
175
167
176
168
## Retrieve output data
177
169
@@ -202,7 +194,7 @@ The Azure portal displays task output files and logs that are persisted to a lin
202
194
To enable the display of your output files in the portal, you must satisfy the following requirements:
203
195
204
196
1.[Link an Azure Storage account](#requirement-linked-storage-account) to your Batch account.
205
-
2. Adhere to the predefined naming conventions for Storage containers and files when persisting outputs. You can find the definition of these conventions in the File Conventions library [README][github_file_conventions_readme]. If you use the [Azure Batch File Conventions][nuget_package] library to persist your output, your files are persisted according to the File Conventions standard.
197
+
1. Adhere to the predefined naming conventions for Storage containers and files when persisting outputs. You can find the definition of these conventions in the File Conventions library [README][github_file_conventions_readme]. If you use the [Azure Batch File Conventions][nuget_package] library to persist your output, your files are persisted according to the File Conventions standard.
206
198
207
199
To view task output files and logs in the Azure portal, navigate to the task whose output you are interested in, then click either **Saved output files** or **Saved logs**. This image shows the **Saved output files** for the task with ID "007":
Starting with version 2017-05-01, the Batch service API supports persisting output data to Azure Storage for tasks and job manager tasks that run on pools with the virtual machine configuration. When you add a task, you can specify a container in Azure Storage as the destination for the task's output. The Batch service then writes any output data to that container when the task is complete.
23
+
The Batch service API supports persisting output data to Azure Storage for tasks and job manager tasks that run on pools with the virtual machine configuration. When you add a task, you can specify a container in Azure Storage as the destination for the task's output. The Batch service then writes any output data to that container when the task is complete.
25
24
26
-
An advantage to using the Batch service API to persist task output is that you do not need to modify the application that the task is running. Instead, with a few simple modifications to your client application, you can persist the task's output from within the code that creates the task.
25
+
An advantage to using the Batch service API to persist task output is that you do not need to modify the application that the task is running. Instead, with a few modifications to your client application, you can persist the task's output from within the same code that creates the task.
27
26
28
27
## When do I use the Batch service API to persist task output?
29
28
@@ -34,7 +33,10 @@ Azure Batch provides more than one way to persist task output. Using the Batch s
34
33
- You want to persist output to an Azure Storage container with an arbitrary name.
35
34
- You want to persist output to an Azure Storage container named according to the [Batch File Conventions standard](https://github.com/Azure/azure-sdk-for-net/tree/psSdkJson6/src/SDKs/Batch/Support/FileConventions#conventions).
36
35
37
-
If your scenario differs from those listed above, you may need to consider a different approach. For example, the Batch service API does not currently support streaming output to Azure Storage while the task is running. To stream output, consider using the Batch File Conventions library, available for .NET. For other languages, you'll need to implement your own solution. For more information on other options for persisting task output, see [Persist job and task output to Azure Storage](batch-task-output.md).
36
+
> [!NOTE]
37
+
> The Batch service API does not support persisting data from tasks running in pools created with the cloud service configuration. For information about persisting task output from pools running the cloud services configuration, see [Persist job and task data to Azure Storage with the Batch File Conventions library for .NET to persist ](batch-task-output-file-conventions.md).
38
+
39
+
If your scenario differs from those listed above, you may need to consider a different approach. For example, the Batch service API does not currently support streaming output to Azure Storage while the task is running. To stream output, consider using the Batch File Conventions library, available for .NET. For other languages, you'll need to implement your own solution. For more information on other options for persisting task output, see [Persist job and task output to Azure Storage](batch-task-output.md).
To specify output files for a task, create a collection of [OutputFile](https://docs.microsoft.com/dotnet/api/microsoft.azure.batch.outputfile) objects and assign it to the [CloudTask.OutputFiles](https://docs.microsoft.com/dotnet/api/microsoft.azure.batch.cloudtask.outputfiles#Microsoft_Azure_Batch_CloudTask_OutputFiles) property when you create the task.
72
+
To specify output files for a task, create a collection of [OutputFile](https://docs.microsoft.com/dotnet/api/microsoft.azure.batch.outputfile) objects and assign it to the [CloudTask.OutputFiles](https://docs.microsoft.com/dotnet/api/microsoft.azure.batch.cloudtask.outputfiles#Microsoft_Azure_Batch_CloudTask_OutputFiles) property when you create the task.
71
73
72
-
The following .NET code example creates a task that writes random numbers to a file named `output.txt`. The example creates an output file for `output.txt` to be written to the container. The example also creates output files for any log files that match the file pattern `std*.txt` (_e.g._, `stdout.txt` and `stderr.txt`). The container URL requires the SAS that was created previously for the container. The Batch service uses the SAS to authenticate access to the container:
74
+
The following C# code example creates a task that writes random numbers to a file named `output.txt`. The example creates an output file for `output.txt` to be written to the container. The example also creates output files for any log files that match the file pattern `std*.txt` (_e.g._, `stdout.txt` and `stderr.txt`). The container URL requires the SAS that was created previously for the container. The Batch service uses the SAS to authenticate access to the container:
73
75
74
76
```csharp
75
77
newCloudTask(taskId, "cmd /v:ON /c \"echo off && set && (FOR /L %i IN (1,1,100000) DO (ECHO !RANDOM!)) > output.txt\"")
@@ -99,7 +101,7 @@ new CloudTask(taskId, "cmd /v:ON /c \"echo off && set && (FOR /L %i IN (1,1,1000
99
101
100
102
Whenyouspecifyanoutputfile, youcanusethe [OutputFile.FilePattern](https://docs.microsoft.com/dotnet/api/microsoft.azure.batch.outputfile.filepattern#Microsoft_Azure_Batch_OutputFile_FilePattern) property to specify a file pattern for matching. The file pattern may match zero files, a single file, or a set of files that are created by the task.
101
103
102
-
The**FilePattern**propertysupportsstandardfilesystemwildcardssuchas `*` (fornon-recursivematches) and `**` (forrecursivematches). Forexample, thecodesampleabovespecifiesthefilepatterntomatch `std*.txt` non-recursively:
104
+
The**FilePattern**propertysupportsstandardfilesystemwildcardssuchas `*` (fornon-recursivematches) and `**` (forrecursivematches). Forexample, thecodesampleabovespecifiesthefilepatterntomatch `std*.txt` non-recursively:
103
105
104
106
`filePattern: @"..\std*.txt"`
105
107
@@ -111,7 +113,7 @@ To upload a single file, specify a file pattern with no wildcards. For example,
111
113
112
114
The [OutputFileUploadOptions.UploadCondition](https://docs.microsoft.com/dotnet/api/microsoft.azure.batch.outputfileuploadoptions.uploadcondition#Microsoft_Azure_Batch_OutputFileUploadOptions_UploadCondition) property permits conditional uploading of output files. A common scenario is to upload one set of files if the task succeeds, and a different set of files if it fails. For example, you may want to upload verbose log files only when the task fails and exits with a nonzero exit code. Similarly, you may want to upload result files only if the task succeeds, as those files may be missing or incomplete if the task fails.
FormoreinformationaboutvirtualdirectoriesinAzureStorage, see [Listtheblobsinacontainer](../storage/blobs/storage-quickstart-blobs-dotnet.md#list-the-blobs-in-a-container).
145
147
146
-
147
148
## Diagnose file upload errors
148
149
149
-
IfuploadingoutputfilestoAzureStoragefails, thenthetaskmovestothe**Completed**stateandthe [TaskExecutionInformation.FailureInformation](https://docs.microsoft.com/dotnet/api/microsoft.azure.batch.taskexecutioninformation.failureinformation#Microsoft_Azure_Batch_TaskExecutionInformation_FailureInformation) property is set. Examine the **FailureInformation** property to determine what error occurred. For example, here is an error that occurs on file upload if the container cannot be found:
150
+
IfuploadingoutputfilestoAzureStoragefails, thenthetaskmovestothe**Completed**stateandthe [TaskExecutionInformation.FailureInformation](https://docs.microsoft.com/dotnet/api/microsoft.azure.batch.taskexecutioninformation.failureinformation#Microsoft_Azure_Batch_TaskExecutionInformation_FailureInformation) property is set. Examine the **FailureInformation** property to determine what error occurred. For example, here is an error that occurs on file upload if the container cannot be found:
0 commit comments