简体   繁体   English

如何从 azure 作业批处理中的任务返回错误,以便可以重新激活任务?

[英]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:伪代码步骤:

Extra stuff额外的东西

Hope this helps!希望这可以帮助! Thanks =)谢谢 =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从事件处理程序返回任务? - How can i return a task from an eventhandler? 如何从任务异步返回WCF响应中的流? - How can I return a stream in a WCF response asynchronously from a task? 我如何告诉 Moq 返回任务? - How can I tell Moq to return a Task? 如何使用 Task 在 Quartz 中安排作业<IScheduler>调度器 - How I can Schedule Job in Quartz using Task<IScheduler> scheduler 如何从 Visual Studio 测试任务中设置 Azure DevOps 变量,以便以下内联 PowerShell 脚本可以读取它? - How to set Azure DevOps variable from Visual Studio Test task so the following inline PowerShell script can read it? 如何从异步 function C# 返回字符串而不是 SYSTEM.THREADING.TASK.TASK`1[SYSTEM.STRING] - How can I return a string rather than SYSTEM.THREADING.TASK.TASK`1[SYSTEM.STRING] from an async function C# 我怎样才能生成任务 <Task> 打开包装 - How can I produce a Task<Task> to Unwrap 如何从Task返回结果? - How to return the result from Task? 如何在测试任务中分析 azure devops 管道中的超时 - How can I analyze a timeout in a azure devops pipeline in test task 如何在任务完成之前返回但保持运行? - How can I return before a task completes but keep it running?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM