Seamlessly deploy a new version of app to Virtual Machine Scale Set

Jan Vávra 251 Reputation points
2023-10-03T07:28:33.8633333+00:00

Hello,
in the docs there is a sample how to deploy a new version of app: https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/tutorial-install-apps-powershell

But I'd like to make it with no errors that could be noticed from the customer side.
Now I manually do on VMs behind a load balancer these steps:

  1. Remove machine from backend pool
  2. Wait until there is no incoming connection using Process Explorer or netstat.
    It there would be any and I would have stopped a web server, the customer will notice a TCP connection reset error.
  3. Deploy a new version of an app
  4. Run some smoke tests
  5. Return the VM into the backend pool

How should I do with a Load Balancer and VMSS?
Should I script all these five steps?

Will the Custom Script Extension wait until all these 5 steps will be done?
I am afraid if the script execution will be spread in parallel, there doesn't have to left over any alive vm instance.

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.
348 questions
{count} votes

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 24,206 Reputation points Microsoft Employee
    2023-10-04T05:45:43.8466667+00:00

    Hello Jan Vávra

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    To deploy a new version of your application to a VMSS with no errors that could be noticed from the customer side, you can follow these steps:

    1. Create a new custom VM image with the updated version of your application pre-installed.
    2. Create a new scale set with the new custom VM image.
    3. Use the Azure Load Balancer to route traffic to the new scale set.
    4. Remove the old scale set from the backend pool of the load balancer.
    5. Wait until there are no incoming connections to the old scale set.
    6. Stop the web server on the old scale set.
    7. Deploy the new version of your application to the new scale set.
    8. Run some smoke tests on the new scale set to ensure that the new version of your application is working correctly.
    9. Add the new scale set to the backend pool of the load balancer.
    10. Remove the old scale set.

    You can use the Custom Script Extension to install and configure software on your VM instances. The Custom Script Extension downloads and runs scripts on the VM instances in your scale set. You can use this extension to install and configure software on your VM instances.

    The Custom Script Extension will not wait until all the steps are done. You will need to script all these five steps and ensure that they are executed in the correct order. You can use Azure PowerShell or Azure CLI to script these steps.

    To avoid leaving any alive VM instances, you can use Azure Traffic Manager to route traffic to the new scale set gradually. You can start by routing a small percentage of traffic to the new scale set and gradually increase the percentage as you verify that the new version of your application is working correctly.

    Hope this helps.