Aminion
Aminion

Reputation: 465

Bug with Azure Batch, initializing job object from taskitem

To add a task, as shown in the official tutorial from Microsoft, I have to make a chain of initialization. Here is the code.

var cred = new BatchCredentials(Credentials.AzureBatch.Name, Credentials.AzureBatch.AccountKey);
        var batchClient = BatchClient.Connect(Credentials.AzureBatch.Uri, cred);
        var workItemManager = batchClient.OpenWorkItemManager();
        _job = workItemManager.GetJob(Credentials.AzureBatch.Name, "job-0000000001");

Problem is that the code execution stops on the next line.

_job = workItemManager.GetJob(Credentials.AzureBatch.Name, "job-0000000001");

Then throws an exception with the description {"The remote server returned an error: (404) Not Found."}. I assume, job with the same name is not found on the server. But according to the tutorial, the name given job at its automatic creation, together with the creation of workitem. What's wrong?

Upvotes: 1

Views: 382

Answers (3)

JackMith
JackMith

Reputation: 45

download the batch explorer code from here.. https://github.com/Azure/azure-batch-samples/tree/master/CSharp/BatchExplorer

Upvotes: 0

Yiding Zhou
Yiding Zhou

Reputation: 386

Your code doesn't show the workitem creation part, I assume you have already done so. If not, you need to create the workitem first.

Workitem and job creation are not synchronize. So, it's possible that your workitem has been created but not the job. Just catch the exception and retry until you find the job.

@ccoxton is right that you can download the Batch Explorer from https://code.msdn.microsoft.com/windowsazure/Azure-Batch-Explorer-c1d37768. This should give you a view on what's happening on the server.

Upvotes: 1

ccoxtn
ccoxtn

Reputation: 1602

Download the Azure Batch Explorer application, and connection your account to it. This will show you the running pools, work items, and jobs. You must have a running work item for that code to work. There could have been a problem with the code you used to create the work item.

Upvotes: 0

Related Questions