Updating VHD of Azure VM ScaleSet

2019-07-18 11:21发布

I have created a VMSS on Azure using the vhd of my Azure VM.

How can I change the source vhd of VMSS to a new vhd ?

Get the following error: enter image description here

2条回答
Evening l夕情丶
2楼-- · 2019-07-18 11:34

AS per the FAQ on VMSS and VM in general, the VMSS runs on top of VHD. So, if you have a new VHD, then you could simply delete the old VMSS, and create a new VMSS.

here is how I picture your situation to be.

  1. VMSS running top of VHD1
  2. Now, I have VHD2.
  3. Create new VMSS using VHD2 as the base.
  4. Delete VMSS running on top of VHD1
  5. Delete VHD1 as well if that is no longer required, and or push it to some backup for later reuse.

the issue itself seems straightforward, unless you are asking for something else, and I am making a fool of myself :)

if the issue is something else, then the question needs to be explained a little more so other, more experience azure folks can help you.

查看更多
Bombasti
3楼-- · 2019-07-18 11:55

We can use Update-AzureRmVmss and Update-AzureRmVmssInstance to upgrade VMSS instance.

If we want to use custom image to upgrades Azure VMSS instances, we should make sure this VMSS create by custom image.

If we create VMSS from Azure marketplace, we can’t use custom image to upgrades Azure VMSS instances.

Here is my test:

1.I create VMSS by custom image, and use VMSS template to create it(managed disk).

enter image description here

2, create another VM image, and use this script to get the $vmss, and use Powershell to upgrades VMSS instances:

$rgname = "vmsss"
$vmssname = "jasonvmss"
$instanceid = "1"
$newimagereference = "/subscriptions/5384xxxx-xxxx-xxxx-xxxx-xxxxe29axxxx/resourceGroups/jasonwin/providers/Microsoft.Compute/images/myImage"
$vmss = Get-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssname
$vmss.virtualMachineProfile.storageProfile.imageReference.id = $newImageReference
Update-AzureRmVmss -ResourceGroupName $rgname -Name $vmssname -VirtualMachineScaleSet $vmss
Update-AzureRmVmssInstance -ResourceGroupName $rgname -VMScaleSetName $vmssname -InstanceId $instanceId

Here is my screenshot:

enter image description here

Also we can find the status of VMSS instances:

enter image description here

So, as a workaround, we can use template or PowerShell to create Azure VMSS with custom image, then use this script to upgrades Azure VMSS instances.

Note: In my test, I am use template create VMSS was managed disk, so we should use $vmss.virtualMachineProfile.storageProfile.imageReference.id

If you create VMSS was un-managed disk, we should use this $vmss.virtualMachineProfile.storageProfile.osDisk.image.uri= $newURI.

Here is the official article about upgrades VMSS instances, please refer to it.

查看更多
登录 后发表回答