Search code examples
azureazure-cliazure-vm-scale-set

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


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?


Solution

  • 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