1

I want to use azure cli command to change the reference image of vmss and update the vm running under the vmss.

I used to use UI to update the reference image as shown below.

enter image description here

I tried following https://learn.microsoft.com/en-US/cli/azure/vmss?view=azure-cli-latest#az_vmss_update

but not getting exact command, am I going in wrong direction?

Komal Nagada
  • 89
  • 1
  • 5

2 Answers2

2

This is the CLI command I have used

az vmss update --name MyScaleSet --resource-group MyResourceGroup --set virtualMachineProfile.storageProfile.imageReference.id=imageID
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
kislay
  • 21
  • 3
  • Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, **can you [edit] your answer to include an explanation of what you're doing** and why you believe it is the best approach? – Jeremy Caney Feb 10 '23 at 21:55
1

I have tested in my environment to change the reference images of VMSS but it seems not possible using below cmd.

Update-AzVmss ` -ResourceGroupName "myResourceGroup" ` -VMScaleSetName "myScaleSet" ` -ImageReferenceId /subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/myNewImage 

enter image description here

If you want to update the version of reference image you can change with the below command.

Update-AzVmss -ResourceGroupName "myResourceGroup" -VMScaleSetName "myScaleSet" -ImageReferenceVersion 16.04.201801090
AjayKumarGhose
  • 4,257
  • 2
  • 4
  • 15