The Azure Batch API provides the list function, which retrieves an enumerable list of tasks in a job, which takes TaskListOptions, to, for instance, filter the tasks by state.
I would like to query the API only for the number of tasks in a particular state and the API does not provide a function for that. I can do it by downloading an enumerating all the tasks, for instance like so:
n = sum(1 for t in bsc.task.list(job.id, bm.TaskListOptions(filter="state eq 'Completed'")))
This is of course horribly slow. The OData specification does provide the $count
query option, but I can't find a way to add that onto the query. Is there a way to use $count
with the Batch API, or is there perhaps a completely different alternative, e.g., via raw REST queries bypassing the Batch API?