Reputation: 150
I have implemented an Azure Batch example using a template based on the following sample:
https://github.com/Azure/azure-batch-samples/tree/master/CSharp/TextSearch
My solution creates a Job Manager task, which in turn creates multiple child tasks for each of my divisions. I am receiving a "BadRequest
" error when I call batchClient.JobOperations.AddTaskAsync
in the code below:
Console.WriteLine("Submitting {0} mapper tasks.", extracts.Count());
//The collection of tasks to add to the Batch Service.
List<CloudTask> tasksToAdd = new List<CloudTask>();
// Create Batch jobs
foreach (var extract in extracts)
{
// ToDo: Uncomment this
// extractService.SetStatus(extract.Id, WarehouseMasterConstants.eExtractStatus.Queuing);
string taskId = Helpers.GetSummarizeDivisionTaskId(extract.Id);
Console.WriteLine("Task Id: " + taskId);
string commandLine = string.Format("{0} {1}", SummarizeDivisionConstants.SummarizeDivisionTaskExecutable, extract.Id.ToString());
Console.WriteLine("Command Line: " + commandLine);
CloudTask unboundMapperTask = new CloudTask(taskId, commandLine);
//The set of files (exes, dlls and configuration files) required to run the mapper task.
IReadOnlyList<string> mapperTaskRequiredFiles = SummarizeDivisionConstants.RequiredExecutableFiles;
List<ResourceFile> mapperTaskResourceFiles = BatchHelpers.GetResourceFiles(containerSas, mapperTaskRequiredFiles);
unboundMapperTask.ResourceFiles = mapperTaskResourceFiles;
tasksToAdd.Add(unboundMapperTask);
}
//Submit the unbound task collection to the Batch Service.
//Use the AddTask method which takes a collection of CloudTasks for the best performance.
await batchClient.JobOperations.AddTaskAsync(this.jobId, tasksToAdd);
I have confirmed by storage and batch credentials are correct and functioning.
Any suggestions in determining why I am getting a BadRequest
would be appreciated.
Stack Trace:
Unhandled Exception: System.AggregateException: One or more errors occurred. ---> Microsoft.Azure.Batch.ParallelOperationsException: One or more requests to the Azure Batch service failed. ---> Microsoft.Azure.Batch.Common.BatchException: Operation returned an invalid status code 'BadRequest' ---> Microsoft.Azure.Batch.Protocol.Models.BatchErrorException: Operation returned an invalid status code 'BadRequest'\r\n at Microsoft.Azure.Batch.Protocol.TaskOperations.d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Batch.Protocol.BatchRequestBase
2.<ExecuteRequestWithCancellationAsync>d__43.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.T askAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Batch.Protocol.BatchRequestBase
2.d__40.MoveNext()\r\n --- End of inner exception stack trace ---\r\n at Microsoft.Azure.Batch.Protocol.BatchRequestBase2.<ExecuteRequestAsync>d__40.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Batch.ProtocolLayer.<ProcessAndExecuteBatchRequest>d__83
1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\r\n at Microsoft.Azure.Batch.AddTasksWorkflowManager.d__16.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Batch.AddTasksWorkflowManager.d__19.MoveNext()\r\n --- End of inner exception stack trace ---\r\n at Microsoft.Azure.Batch.AddTasksWorkflowManager.d__19.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Ba tch.AddTasksWorkflowManager.d__18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Batch.AddTasksWorkflowManager.d__13.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Batch.JobOperations.d__43.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotifica tion(Task task)\r\n
Upvotes: 0
Views: 3111
Reputation: 150
Fixed the problem. My Task id included the executable name, which had "." in it. Replaced the "." with a "-" and it worked.
Upvotes: 0