0
votes

I have hosted a website in azure virtual machine scale set by following the below steps

  1. Create a VM and do the necessary changes/installations in iis.
  2. Create a snapshot of the VM. This ensure that the above instance can be used for future changes.
  3. create a disk from the snapshot.
  4. create a vm from the disk.
  5. RDP to the instance and generalize the instance for deployment (sysprep)
    Run %WINDIR%\system32\sysprep\sysprep.exe as admin. Enter System Out-of-Box Experience (OOBE), Generalize check box is selected Shutdown Option = Shutdown
  6. Create Image (capture) from the above instance.
  7. Create VSS from the above image

Suppose their is a change in the web build , Is there a way to update the scale set without following these steps again ?

1

1 Answers

0
votes

Azure virtual machine extensions provide capabilities such as post-deployment configuration and management, monitoring, security, and more. Production deployments typically use a combination of multiple extensions configured for the VM instances to achieve desired results.

This is also is a good way to ensure availability of your system. The scale set will apply the update to one VM at a time, leaving the other VMs up and running.

Below example taken from the learn:

Deploy the update by using a custom script extension In the Azure portal, run the following command to view the current upgrade policy for the scale set:

Azure CLI:    
az vmss show \
        --name webServerScaleSet \
        --resource-group scalesetrg \
        --query upgradePolicy.mode

Verify that the upgrade policy is set to Automatic. You specified this policy when you created the scale set in the first lab. If the policy were Manual, you would apply any VM changes by hand. Because the policy is Automatic, you can use the custom script extension and allow the scale set to do the update.

Run the following command to apply the update script:

az vmss extension set \
    --publisher Microsoft.Azure.Extensions \
    --version 2.0 \
    --name CustomScript \
    --vmss-name webServerScaleSet \
    --resource-group scalesetrg \
    --settings "{\"commandToExecute\": \"echo This is the updated app installed on the Virtual Machine Scale Set ! > /var/www/html/index.html\"}"