Azure 自动缩放组中 VM 的应用程序版本管理



当前,我正在使用自动化的Azure VM运行的应用程序。因此,假设我当前版本的应用程序,即1.0是根据当前应用程序负载为4 VM提供的。现在,如果我有一个补丁更新并发布新版本的应用程序,即2.0,那么该新版本的应用程序将如何更新到当前VM的运行中?如果负载增加并且新的VM启动,他们都将拥有此新版本的应用程序2.0,但是先前运行的4 VM,他们是否会拥有此新版本的应用程序?如果是,如何?

您必须从ARM模板中启动具有自定义图像作为源图像而不是来自市场图像的Azure VMS。要更新VM上的应用程序,请再次创建具有更新应用程序的VM的自定义映像,然后使用PowerShell在VMS中更新此新VM。然后,Azure VMS自动更新具有更新图像的规模设置中的所有VM。以下是用于使用新自定义图像更新现有VMS的代码。

    $rgname = "myrg"
    $vmssname = "myvmss"
    # get the VMSS model
    $vmss = Get-AzureRmVmss -ResourceGroupName $rgname -VMScaleSetName $vmssname
    # set the new version in the model data
    $vmss.virtualMachineProfile.storageProfile.imageReference.id = $newImageReference
    # update the virtual machine scale set model
    Update-AzureRmVmss -ResourceGroupName $rgname -Name $vmssname -VirtualMachineScaleSet $vmss
    # now start updating instances
    Update-AzureRmVmssInstance -ResourceGroupName $rgname -VMScaleSetName $vmssname -InstanceId $instanceId

相关内容

最新更新