I’m currently having a PHP application running in an Azure VM, now I have moved that setup to a VMSS and Load Balancer and having a VM as staging. But now, when the developer make a change each time, They will do that to the staging VM and I will take a snapshot of the image and update the VMSS image with the new version of the image. This is really a bad process. So I thought to have Azure DevOps in place to take care of the deployment. But I couldn’t figure out how we can deploy to VMSS instances. I have seen the Microsoft Documentation, but didn’t help much.
My idea towards it is deploying the application to the staging VM and take the image and update the VMSS all in CD pipeline process with CLI scripts.
I need some one to check whether my idea is correct or is there any better solution. If you need any further details or clarification to help me, please let me know.
2
Answers
The exact answer depends on Linux or Windows.
Images can be useful. If your PHP app has a bunch of dependencies that have to be installed/configued and rarely change then baking this into an image can speed things up. However for the application itself it likely makes more sense to install the app after deploying the image. If your app rarely changes maybe it makes sense to then update the image to make your scaling faster.
Check out:
https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-deploy-app
If you would like to host your PHP app on the instances of Azure VMSS and deploy the application onto all instances instead of updating the VM image, you can install the extension
Azure Pipeline Agent For Linux
which will configure each instance of the VMSS to be a target in the deployment group, so that we can use deployment group job in a release pipeline to roll out the deployment.If you would like to deploy app on one of the VMSS instances and capture a new VM image based on this instance and then update the image reference for your VMSS resource, you may test the steps below.
azvmss-ub000000
) as a self-hosted agent to deploy app via the agent job running on it;azvmss-ub000000
, I run the Azure CLI commands to capture new VM image based on its managed disk; here is the sample script from theAzureCLI
pipeline task running on MS-hosted agents; kindly note that you may leverage other methods to capture VM image and update the image reference and then integrate the commands into release pipeline; in all cases, please use the VMSS resource in test environment to examine the workflow in order to avoid missing data on your VMs from production environment;By the way, you may also consider hosting your app on Azure App Services or AKS; Azure DevOps Services have corresponding tasks for deployment.
Build and test PHP apps – Azure Pipelines | Microsoft Learn
Deploy to Azure Kubernetes Service with Azure Pipelines – Azure Kubernetes Service | Microsoft Learn