Managing Instances in Azure VMSS Autoscaling

SafiyullahSA 85 Reputation points
2024-10-22T16:57:27.81+00:00

Details: I have a Virtual Machine Scale Set (VMSS) configured with custom autoscaling.

Goal: To delete an instance in VMSS and update the scaling configuration.

Scenario: The VMSS is currently set with a minimum count of 5. There are 5 instances running, and I have stopped a specific instance. If I change the scale set value from a minimum count of 5 to 4, will the stopped instance be automatically deleted, or will another instance be deleted?

Should the instance be deleted first before updating the autoscale rule?

Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
410 questions
{count} votes

Accepted answer
  1. Sina Salam 12,011 Reputation points
    2024-10-22T20:06:48.1033333+00:00

    Hello SafiyullahSA,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you would like to manage instances in Azure VMSS Autoscaling.

    To automatically delete stopped instances and update autoscaling rules in Azure Virtual Machine Scale Sets (VMSS), you can use a combination of autoscaling configurations and custom scale-in policies. Autoscaling can be set up to automatically adjust the number of VM instances based on CPU usage or other metrics. If you have VMs that are stopped, they won't contribute to the CPU usage, but they may still exist within the scale set. You can configure a custom scale-in policy to remove stopped or idle VMs by using options such as "OldestVM" or "NewestVM" to dictate which VMs should be removed first.

    To achieve this, you can modify the autoscale configuration using the Azure CLI, PowerShell, or the Azure portal, ensuring that your scaling policies are in place and that your VMSS is using the appropriate orchestration mode (default is now "Flexible"). Additionally, you can manually trigger deletion of stopped instances via scripting using commands like az vmss update or configure autoscaling rules to handle it automatically based on performance thresholds.

    For a clearer picture, to control which instance is deleted, it's recommended to know the stopped instance first, then delete the stopped instance. Then, you can update the autoscaling configuration, ensuring the VMSS retains only the active instances you intend to keep. For more detailed guidance on implementing these policies and configuration options:

    Also, utilize the documentation by the right side of this page for further reading.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.