I want to execute a simple task in Azure Batch, to wait until it completes and to get the result:
using (var client = _CreateBatchClient())
{
var monitor = client.Utilities.CreateTaskStateMonitor();
var task = new CloudTask(Guid.NewGuid().ToString(), "echo hello world");
await client.JobOperations.AddTaskAsync("Test", task);
await monitor.WhenAll(new List<CloudTask> { task }, TaskState.Completed, _timeout);
var result = task.ExecutionInformation.Result;
}
And the WhenAsync
line throws System.InvalidOperationException: 'This operation is forbidden on unbound objects.'
The message is quite obscure whereas I am not far from the tutorial. What is wrong?