[英]How can I return error from a task in azure job batch so task may be reactivated?
I want that when a job executes, in azure batch service, in case of an error to be able to correct data and then from portal just reactivate the task.我希望当作业执行时,在 azure 批处理服务中,如果出现错误能够更正数据,然后从门户重新激活任务。 The tasks are scheduled.
任务已安排。
Currently I am just throwing Exceptions in case of failure.目前我只是在失败的情况下抛出异常。 Those tasks cannot be reactivated.
这些任务无法重新激活。
But looking at other tasks I see this "Task failed "The task exited with an exit code representing a failure"" For that task I can click on 'Reactivate' button.但是在查看其他任务时,我看到了这个“任务失败”任务以表示失败的退出代码退出“”对于该任务,我可以单击“重新激活”按钮。 How can I do the same?
我该怎么做?
This is my current code:这是我当前的代码:
public class Program
{
private static void Main(string[] args)
{
try
{
ConsoleLogger.Info($"Job.DataTransfer process started! ");
DataTransferSettings dataTransferSettings = DataTransferSettingsReader.GetDataTransferSettings();
if (dataTransferSettings != null)
{
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
CopyData(dataTransferSettings);
}
else
{
throw new Exception($"Process stopped, check data transfer settings.");
}
ConsoleLogger.Info($"Job.DataTransfer process completed.");
}
catch (Exception ex)
{
ConsoleLogger.Error(GetExceptionMessage(ex), ex);
ExceptionDispatchInfo.Capture(ex).Throw();
}
}
}
I just didn't found yet any solution on how to do this.我只是还没有找到任何关于如何做到这一点的解决方案。
So here is how you can handle it or the links below will give you good ideas how you can choose to handle.所以这里是你可以如何处理它,或者下面的链接会给你很好的想法,你可以选择如何处理。
Have a play around with the sample code here: c# samples reside here: https://github.com/Azure-Samples/azure-batch-samples/tree/master/CSharp/GettingStarted You will see some stuff here as to how you can handle the failing task: https://github.com/Azure-Samples/azure-batch-samples/blob/master/CSharp/GettingStarted/02_PoolsAndResourceFiles/JobSubmitter/JobSubmitter.cs在这里玩一下示例代码:c# 示例驻留在此处: https://github.com/Azure-Samples/azure-batch-samples/tree/master/CSharp/GettingStarted您将在这里看到一些关于您如何可以处理失败的任务: https://github.com/Azure-Samples/azure-batch-samples/blob/master/CSharp/GettingStarted/02_PoolsAndResourceFiles/JobSubmitter/JobSubmitter.cs
Pseudo code steps:伪代码步骤:
Task exit code: https://docs.microsoft.com/en-us/azure/batch/error-handling#task-exit-codes任务退出代码: https://docs.microsoft.com/en-us/azure/batch/error-handling#task-exit-codes
Extra stuff额外的东西
Hope this helps!希望这可以帮助! Thanks =)
谢谢 =)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.