question

haiqianz-8184 avatar image
0 Votes"
haiqianz-8184 asked srbose-msft answered

How can I pass newest customdata to VMs in the VMSS

I have a case that I need to reimage the VMs in my VMSS so that they can run with the newest customdata on VMSS. What's the right flow to do that?

Details:
1. I updated VMSS with my new customdata
2. I need to restart my VMs in this VMSS but how can they run with the newest customData in VMSS?

azure-cloud-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

srbose-msft avatar image
0 Votes"
srbose-msft answered

@haiqianz-8184 , Thank you for your question.

For VMSS, you can update VMSS custom data via REST API (not applicable for PS or AZ CLI clients). When you update custom data in the VMSS model:

Existing instances in the VMSS will not get the updated custom data, only until they are reimaged.
Existing instances in the VMSS that are upgraded will not get the updated custom data.
New instances will receive the new custom data.

For more information please refer to this article.


You can do this reimage via:

  • REST API with compute/virtualmachinescalesets/reimage as follows:
    POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/myScaleSet/reimage?api-version={apiVersion}

  • Azure PowerShell with Set-AzVmssVm:
    Set-AzVmssVM -ResourceGroupName "myResourceGroup" -VMScaleSetName "myScaleSet" -InstanceId instanceId -Reimage

  • Azure CLI with az vmss reimage:
    az vmss reimage --resource-group myResourceGroup --name myScaleSet --instance-id instanceId

  • You can also use the language-specific Azure SDKs.

[Reference]


Hope this helps.

Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.