我已经使用基于以下示例的模板实现了 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);
我已通过存储和批处理凭据确认正确且正常运行。
任何关于确定我为什么得到 a 的BadRequest
建议将不胜感激。
堆栈跟踪:
未处理的异常:System.AggregateException:发生一个或多个错误。---> Microsoft.Azure.Batch.ParallelOperationsException:对 Azure Batch 服务的一个或多个请求失败。---> Microsoft.Azure.Batch.Common.BatchException:操作返回无效状态代码“BadRequest”---> Microsoft.Azure.Batch.Protocol.Models.BatchErrorException:操作返回无效状态代码“BadRequest”\r \n 在 Microsoft.Azure.Batch.Protocol.TaskOperations.d__7.MoveNext()\r\n--- 从先前引发异常的位置结束堆栈跟踪 ---\r\n 在 System.Runtime.CompilerServices。 TaskAwaiter.ThrowForNonSuccess(任务任务)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\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(Task task)\r\n 在 System .Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(任务任务)\r\n 在 Microsoft.Azure.Batch.AddTasksWorkflowManager.d__16.MoveNext()\r \n--- 从先前引发异常的位置结束堆栈跟踪 ---\r\n 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n 在 System.Runtime.CompilerServices.TaskAwaiter。 HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 Microsoft.Azure.Batch.AddTasksWorkflowManager.d__19.MoveNext()\r\n --- 内部异常堆栈跟踪结束 ---\r\n 在 Microsoft.Azure.Batch。AddTasksWorkflowManager.d__19.MoveNext()\r\n--- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)处从先前引发异常的位置结束堆栈跟踪 ---\r\n在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n 在 Microsoft.Azure.B tch.AddTasksWorkflowManager.d__18.MoveNext()\r\n--- 堆栈跟踪从上一个异常位置结束抛出 ---\r\n System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\r\n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\n Microsoft.Azure.Batch .AddTasksWorkflowManager.d__13.MoveNext()\r\n--- 在 System.Runtime.CompilerServices.TaskAwaiter 处从先前引发异常的位置结束堆栈跟踪 ---\r\n。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来自先前引发异常的位置的堆栈跟踪 ---\r\n System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\ r\nCompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\nCompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\r\n