简体   繁体   中英

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. 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

Pseudo code steps:

Extra stuff

Hope this helps! Thanks =)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM