1

In my application I create an Azure batch job. It's a Node app and I use an azure-batch Node client, but I could also be using REST, I don't think it matters. I can't switch to a C# client, however.

I expect the job to be completed in a few seconds and I wish to pause the code until the batch job is over but I am not sure how to detect the end of the job without polling the Job Status API. Neither the Node client nor the REST API exposes such functionality. I thought I could maybe register for an event of some sort but was not able to find anything like that. There are job release tasks but I am not sure if I can achieve this using them.

Any ideas how the end of an Azure batch job can be detected from within my application?

Avius
  • 5,504
  • 5
  • 20
  • 42

1 Answers1

0

One way to do this is once you add your tasks to the job, set the job's onAllTasksComplete property to 'terminatejob'.

Then you can poll the Job-Get API, and check the state property on the job for when the job is complete (https://learn.microsoft.com/en-us/rest/api/batchservice/job/get#jobstate or https://learn.microsoft.com/en-us/javascript/api/azure-batch/job?view=azure-node-latest#get-string--object-).

brklein
  • 310
  • 1
  • 6
  • Yep, I had this in mind, but that means that I have to poll. Also, there was a typo in my question, I wrote pooling instead of polling : ] any idea how to do this without polling? – Avius Jan 24 '19 at 09:41
  • 1
    I interpreted 'Neither the Node client nor the REST API exposes such functionality.' as not implementing polling/state functionality. I personally can't think of any non-gimmicky ways strictly through Batch to do event based detection of that. – brklein Jan 24 '19 at 18:47