@haiqianz , 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.
----------
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.