0
votes

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.

1
2 cents for idea: So, this is a task failure you mean? i.e. is taskFailure is visible with non-zero exit code then this is what the right behaviour is, you can get the exit code and fix the task. Can you detail what in the batch end is actually failing please?Tats_innit

1 Answers

0
votes

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 =)