JobOperations.AddTask Method

Definition

Overloads

AddTask(String, CloudTask, IEnumerable<BatchClientBehavior>)

Adds a single task to a job. To add multiple tasks, use AddTask(String, IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>).

AddTask(String, IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>)

Adds tasks to a job.

AddTask(String, CloudTask, IEnumerable<BatchClientBehavior>)

Adds a single task to a job. To add multiple tasks, use AddTask(String, IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>).

public System.Collections.Concurrent.ConcurrentDictionary<Type,Microsoft.Azure.Batch.IFileStagingArtifact> AddTask (string jobId, Microsoft.Azure.Batch.CloudTask taskToAdd, System.Collections.Generic.IEnumerable<Microsoft.Azure.Batch.BatchClientBehavior> additionalBehaviors = null);
member this.AddTask : string * Microsoft.Azure.Batch.CloudTask * seq<Microsoft.Azure.Batch.BatchClientBehavior> -> System.Collections.Concurrent.ConcurrentDictionary<Type, Microsoft.Azure.Batch.IFileStagingArtifact>
Public Function AddTask (jobId As String, taskToAdd As CloudTask, Optional additionalBehaviors As IEnumerable(Of BatchClientBehavior) = null) As ConcurrentDictionary(Of Type, IFileStagingArtifact)

Parameters

jobId
String

The id of the job to which to add the task.

taskToAdd
CloudTask

The CloudTask to add.

additionalBehaviors
IEnumerable<BatchClientBehavior>

A collection of BatchClientBehavior instances that are applied to the Batch service request after the CustomBehaviors.

Returns

A collection of information about the file staging process (see FilesToStage). For more information see IFileStagingArtifact.

Remarks

Each call to this method incurs a request to the Batch service. Therefore, using this method to add multiple tasks is less efficient than using a bulk add method, and can incur HTTP connection restrictions. If you are performing many of these operations in parallel and are seeing client side timeouts, please see http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit%28v=vs.110%29.aspx or use the multiple-task overload of AddTask.

This is a blocking operation. For a non-blocking equivalent, see AddTaskAsync(String, CloudTask, ConcurrentDictionary<Type,IFileStagingArtifact>, IEnumerable<BatchClientBehavior>, CancellationToken).

AddTask(String, IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>)

Adds tasks to a job.

public void AddTask (string jobId, System.Collections.Generic.IEnumerable<Microsoft.Azure.Batch.CloudTask> tasksToAdd, Microsoft.Azure.Batch.BatchClientParallelOptions parallelOptions = null, System.Collections.Concurrent.ConcurrentBag<System.Collections.Concurrent.ConcurrentDictionary<Type,Microsoft.Azure.Batch.IFileStagingArtifact>> fileStagingArtifacts = null, Nullable<TimeSpan> timeout = null, System.Collections.Generic.IEnumerable<Microsoft.Azure.Batch.BatchClientBehavior> additionalBehaviors = null);
member this.AddTask : string * seq<Microsoft.Azure.Batch.CloudTask> * Microsoft.Azure.Batch.BatchClientParallelOptions * System.Collections.Concurrent.ConcurrentBag<System.Collections.Concurrent.ConcurrentDictionary<Type, Microsoft.Azure.Batch.IFileStagingArtifact>> * Nullable<TimeSpan> * seq<Microsoft.Azure.Batch.BatchClientBehavior> -> unit
Public Sub AddTask (jobId As String, tasksToAdd As IEnumerable(Of CloudTask), Optional parallelOptions As BatchClientParallelOptions = null, Optional fileStagingArtifacts As ConcurrentBag(Of ConcurrentDictionary(Of Type, IFileStagingArtifact)) = null, Optional timeout As Nullable(Of TimeSpan) = null, Optional additionalBehaviors As IEnumerable(Of BatchClientBehavior) = null)

Parameters

jobId
String

The id of the job to which to add the tasks.

tasksToAdd
IEnumerable<CloudTask>

The CloudTasks to add.

parallelOptions
BatchClientParallelOptions

Controls the number of simultaneous parallel AddTaskCollection requests issued to the Batch service. Each AddTaskCollection request contains at most MaxTasksInSingleAddTaskCollectionRequest tasks in it. Also controls the cancellation token for the operation. If omitted, the default is used (see BatchClientParallelOptions.)

fileStagingArtifacts
ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>

An optional collection to receive information about the file staging process (see FilesToStage). An entry is added to the ConcurrentBag<T> for each set of tasks grouped for submission to the Batch service. Unlike single-task adds, you cannot use this parameter to customize the file staging process. For more information about the format of each entry, see IFileStagingArtifact.

timeout
Nullable<TimeSpan>

The amount of time after which the operation times out.

additionalBehaviors
IEnumerable<BatchClientBehavior>

A collection of BatchClientBehavior instances that are applied to the Batch service request after the CustomBehaviors.

Exceptions

Thrown if one or more requests to the Batch service fail.

Remarks

This is a blocking operation; for a non-blocking equivalent, see AddTaskAsync(String, IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>).

This method is not atomic; that is, it is possible for the method to start adding tasks and then fail. The collection of tasks to add is broken down into chunks of size at most MaxTasksInSingleAddTaskCollectionRequest, and an AddTaskCollection request is issued for each chunk. Requests may be issued in parallel according to the parallelOptions.

Issuing a large number of simultaneous requests to the Batch service can incur HTTP connection restrictions. If you are performing many of these operations in parallel (or have specified a large MaxDegreeOfParallelism in the parallelOptions) and are seeing client side timeouts, please see http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit%28v=vs.110%29.aspx .

The progress of the operation in the face of errors is determined by AddTaskCollectionResultHandler behavior. You do not normally need to specify this behavior, as the Batch client uses a default which works in normal circumstances. If you do want to customize this behavior, specify an AddTaskCollectionResultHandler in the CustomBehaviors or additionalBehaviors collections.

Applies to