This C# console application demonstrates the use of task dependencies in Azure Batch. With task dependencies, you can configure scenarios such as the following:
- taskB depends on taskA (taskB will not begin execution until taskA has completed)
- taskC depends on both taskA and taskB
- taskD depends on a range of tasks, such as tasks 1 through 10, before it executes
-
Task dependencies require a job with BatchJobCreateOptions.
UsesTaskDependenciesset totrue(the default isfalse). You must set this property value totrueto use task dependencies.var jobOptions = new BatchJobCreateOptions( "MyJob", new BatchPoolInfo { PoolId = "MyPool" }) { UsesTaskDependencies = true, }; await batchClient.CreateJobAsync(jobOptions);
-
When using task ranges for your dependencies, your task IDs must be string representations of integer values.
var tasks = new List<BatchTaskCreateOptions> { new BatchTaskCreateOptions("1", "cmd.exe /c MyTaskExecutable.exe -process data1"), new BatchTaskCreateOptions("2", "cmd.exe /c MyTaskExecutable.exe -process data2"), };