How does auto-scaling decides which VMs to destroy when scaling down?
By default, auto-scaling will delete the larger Instance ID (for example, instances ID are 0,2,3, vmss will delete 3). We can use powershell to get the vmss vms' instance id.
PS C> Get-AzureRmVmssvm -ResourceGroupName "vmss" -VMScaleSetName "vmss"
ResourceGroupName Name Location Sku Capacity InstanceID ProvisioningState
----------------- ---- -------- --- -------- ---------- -----------------
VMSS vmss_0 westus Standard_D1_v2 0 Succeeded
VMSS vmss_2 westus Standard_D1_v2 2 Succeeded
Is there any notification inside the VM that it is scheduled to be
destroyed?
As far as I know, autoscale notifies the administrators and contributors of the resource by email, VM will not receive the notification.
Can a VM that is scheduled to be destroyed control when it gets
destroyed (and hold off destruction until all requests are complete)?
We can't hold off destruction until all requests are complete for now.
In most cases, we deploy vmss with load balancer which using a "round-robin" approach, the VMSS instances will not receive requests until the instances were deleted.
I want to make sure any active long-running requests complete. Is this
possible?
As far as I know, we can choose different OS metrics for autoscale, but we can't make sure VMSS will delete vm instances after the long-running requests complete.