This seems like a basic question but I haven't been able to find an answer googling around.
How does scale sets know that a particular VM has finished what it's doing and is able to be de-provisioned?
From the scale sets FAQ the VMs with the highest IDs are removed first. It doesn't say anything about whether it is mid-task or not.
This is important for my application because my tasks are long running (about 30 minutes on a 1CPU/4GB machine).