我使用基于以下示例的模板实现了Azure Batch示例:
https://github.com/Azure/azure-batch-samples/tree/master/CSharp/TextSearch
我的解决方案创建了一个Job Manager任务,该任务又为我的每个部门创建了多个子任务。我在下面的代码中致电BadRequest
时收到“batchClient.JobOperations.AddTaskAsync
”错误:
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);
我已通过存储和批处理凭证确认正确且正常运行。
任何有关确定我获得BadRequest
的原因的建议都将受到赞赏。
堆栈追踪:
未处理的异常:System.AggregateException:发生了一个或多个错误。 ---&GT; Microsoft.Azure.Batch.ParallelOperationsException:对Azure Batch服务的一个或多个请求失败。 ---&GT; Microsoft.Azure.Batch.Common.BatchException:Operation返回了无效的状态代码'BadRequest'---&gt; Microsoft.Azure.Batch.Protocol.Models.BatchErrorException:Operation在Microsoft.Azure.Batch.Protocol.TaskOperations.d__7.MoveNext()\ r \ n返回无效状态代码'BadRequest'\ r \ n抛出异常的前一个位置的堆栈跟踪--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n \ n在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 ---内部异常堆栈跟踪结束--- \ r \ n在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 ---从抛出异常的前一个位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务任务)\ r \ n在Microsoft.Azure.Batch.AddTasksWorkflowManager.d__16.MoveNext()\ r \ n ---从上一个引发异常的位置的堆栈跟踪结束 - - \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n,在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在Microsoft.Azure.Batch.AddTasksWorkflowManager .d__19.MoveNext()\ r \ n ---内部异常堆栈跟踪结束--- \ r \ n在Microsoft.Azure.Batch.AddTasksWorkflowManager.d__19.MoveNext()\ r \ n ---堆栈结束从抛出异常的先前位置追踪--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \在Microsoft.Azure.Ba tch.AddTasksWorkflowManager.d__18.MoveNext()\ r \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n \ n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在Microsoft.Azure.Batch.AddTasksWorkflowManager.d__13.MoveNext()\ r \ n ---从上一个位置的堆栈跟踪结束抛出--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n,在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在Microsoft.Azure上。 Batch.JobOperations.d__43.MoveNext()\ r \ n ---从抛出异常的上一个位置开始的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotifica (任务任务)\ r \ n
答案 0 :(得分:0)
修正了问题。我的任务ID包含可执行文件名,其中包含“。”在里面。取代了“。”用“ - ”,它有效。