问题
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