Suppose I want to scale up/down my Azure Cloud Service Programmatically. The scaling up case is easy. But when scaling down, can I control which instance gets torn down? Is this predictable?
In my particular use case I have a queue of very long-running operations that I fan out to multiple instances based on some criteria. Each operation might take as long as 20 hours, or as little as 2 minutes.
If I use Wasabi or auto scaling, it looks like random instances are selected for tear down (or usually the most recently added instance...but I can't find a guarantee of that). This won't work particularly well for me. For instance, I could spin up 20 workers to process a queue of 20 work units only to have worker #20 stuck with the 20 hour job.
Is there a way to choose which instance will be torn down (either from within the instance, or from a dedicated management node)?
Yes, the Azure management API will allow you to select specific instances to remove. Starting with version 2013-08-01 of the Azure service management API you can use the Delete Role Instances operation to delete a specific instance(s). You can find detailed information in the Microsoft MSDN page at http://msdn.microsoft.com/library/azure/dn469418.aspx.
There is also an excellent example available at http://gauravmantri.com/2013/10/16/a-new-version-of-windows-azure-service-management-api-is-available-with-delete-specific-role-instances-and-more-goodies/