How can I pass newest customdata to VMs in the VMSS

haiqianz 41 Reputation points
2021-07-15T23:26:25.103+00:00

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
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
696 questions
0 comments No comments
{count} votes

Accepted answer
  1. SRIJIT-BOSE-MSFT 4,336 Reputation points Microsoft Employee
    2021-07-16T05:21:56.177+00:00

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

    [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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.