0
votes

I'm having problems with Azure Batch Jobs. I'm trying to create an app pool, create a CloudTask and then execute my Application Package being online.

Do you see something not working correctly?

Here is the code used now. Main code:

        await CreatePoolAsync(batchClient, currentPoolId, applicationFiles);

        await CreateJobAsync(batchClient, currentJobId, currentPoolId);

        await AddTasksAsync(batchClient, currentJobId, inputFiles, optimizationId, outputContainerSasUrl);

Creating the Pool:

    CloudPool pool = batchClient.PoolOperations.CreatePool(
        poolId: poolId,
        targetDedicated: 1, // 3 compute nodes
        virtualMachineSize: "small", // single-core, 1.75 GB memory, 225 GB disk
        cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "4")); // Windows Server 2012 R2

    pool.ApplicationPackageReferences = new List<ApplicationPackageReference>
    {
        new ApplicationPackageReference
        {
            ApplicationId = "my_app"
        }
    };

Creating the Job:

    CloudJob job = batchClient.JobOperations.CreateJob();
    job.Id = jobId;
    job.PoolInformation = new PoolInformation {PoolId = poolId};

    await job.CommitAsync();

And adding the Task.

    string taskId = "myAppEngineTask";
    string taskCommandLine = $"cmd /c %AZ_BATCH_APP_PACKAGE_MY_APP%\\MyApp.Console.exe -a NSGA2 -r 1000 -m db -i {optimizationId}";

    CloudTask task = new CloudTask(taskId, taskCommandLine);
    task.ApplicationPackageReferences = new List<ApplicationPackageReference>
    {
        new ApplicationPackageReference
        {
            ApplicationId = "my_app"
        }
    };

    await batchClient.JobOperations.AddTaskAsync(jobId, tasks);

When done with adding tasks, everything seems to be up and running, but I get error code: -2146232576 and nothing is printed to any logs.

1

1 Answers

0
votes

To diagnose failures for tasks, you will want to first see if the CloudTask ExecutionInformation.FailureInformation (if SDK 7.0.0+ or ExecutionInformation.SchedulingError if prior SDK version) is set. Examine those fields for any information.

For your particular task, it looks like it could be related to you adding a task-level Application package reference when you have already done that at the pool-level. Try omitting the task.ApplicationPackageReferences.

Consult the Application Package Documentation for more information regarding the difference between Pool-level and Task-level application packages and which one would suit your scenario the best.