VM ScaleSet doesnt run CSE for initial intances

previousversiondocs 51 Reputation points
2023-04-22T15:26:26.7166667+00:00

I have an VMSS with manual scaling + custom script extension (CSE).

The script looks like this:

#!/bash/bin
curl "someurl.com" > /my/path/to/file.txt

In terraform I use it like this:


resource "azurerm_virtual_machine_scale_set_extension" "myext" {
  name                         = "my-ext"
  virtual_machine_scale_set_id = azurerm_linux_virtual_machine_scale_set.vmss.id
  publisher                    = "Microsoft.Azure.Extensions"
  type                         = "CustomScript"
  type_handler_version         = "2.0"
  settings = jsonencode({
    "script" = base64encode(data.local_file.sh.content)
  })
}

The problem I am facing is that when I run terraform apply, the initial instances ( in my case 2) do not apply the CSE. I can see that the CSE does indeed exist in the azure portal, but it is only applied when I press "upgrade" on the selected instances in the azure portal.

Also, when I add a new instance to the VMSS by increasing the count in the portal, the CSE **is applied correctly.

**
Is there anything I am missing?

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.
347 questions
0 comments No comments
{count} votes

Accepted answer
  1. shiva patpi 13,131 Reputation points Microsoft Employee
    2023-04-26T05:05:59.16+00:00

    @previousversiondocs Can you kindly validate & make sure your VMSS Upgrade policy is set to either Automatic or Rolling update ?

    az vmss show --name vmssname --resource-group rgname --query upgradePolicy.mode
    
    https://learn.microsoft.com/en-us/training/modules/build-app-with-scale-sets/7-exercise-update-applications-virtual-machine-scale-sets
    
    
    

    If the upgrade policy was set to Manual , then the CSE extension which was applied at the VMSS level will not be propagated to the underlying Instances unless you do a manual upgrade of the instances or you when you add a new instance! If the upgrade Policy is set to Automatic , then the instances will also get the CSE extension upgrade!

    You can find more details:

    [https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-scale-set]

    (https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-upgrade-scale-set)

    Regards,

    
    

0 additional answers

Sort by: Most helpful