I've created a pool and a job tied to a pool in Azure Batch. After I add a task to the job, I can see that the active tasks from this auto-scale formula returns an array of '1's after a few minutes:
$tasks = $ActiveTasks.GetSample(TimeInterval_Minute * 5); //returns [1,1,1,1,1,1,1,1,1,1]
However, after I terminate & delete the task and wait 30 minutes, Azure still thinks that I have an active task, as the formula evaluates to the same array of '1's. Is there something wrong with this formula?