Applying custom image to an existing azure scaleset which was created using custom image

扶醉桌前 提交于 2021-02-08 10:28:38

问题


I have created an azure scaleset using custom image. when I try to upgrade the scale set with another custom image using "Azure VMSS: update with immutable machine image" I get the following error

Failed to update image for VMSS testvmssapp. Error: VMSS testvmssapp can not be updated as it uses a platform image. Only a VMSS which is currently using a custom image can be updated.

Is there something I am missing with custom scaleset image?

"storageProfile": {
            "osDisk": {
              "createOption": "FromImage",
              "caching": "ReadWrite",
              "managedDisk": {
                "storageAccountType": "Standard_LRS"
              },
              "diskSizeGB": 127
            },
            "imageReference": {
              "id": "/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/testvmssdeployment/providers/Microsoft.Compute/images/MyCustomImage"
            }
          },


回答1:


From OS Updates for a scale set, If you use Azure platform images, you can update the image by modifying the imageReference. With platform images, it is common to specify "latest" for the image reference version. If you use custom images, you can update the image by updating the imageReference ID.

Since you have created a scale set with a base image windows-2012-R2-datacenter. It's deployed from platform Images. It's not supported by changing the image from platform to custom. For more information, please read here1 and here2.

In this case, you could directly recreate a scale set with a new custom Image or remove the old scale set. This is the REST API for creating a scale set from a custom image.




回答2:


I opened an issue here about task Azure VM scale set deployment that you track on.

As workaround, You can try updating the image by using azure powershell task or azure cli task in your pipeline to run below script.

Azure Powershell:

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

Azure CLI:

az vmss update \
    --resource-group myResourceGroup \
    --name myScaleSet \
    --set virtualMachineProfile.storageProfile.imageReference.id=/subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/myNewImage

Another workaround to this issue is to create a VHD file, and use this VHD file to create the VSS using this template. And then you will have a Image resource that has a URL which you can use for task Azure VM scale set deployment. Please check here for information



来源:https://stackoverflow.com/questions/58658792/applying-custom-image-to-an-existing-azure-scaleset-which-was-created-using-cust

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!