Azure Autoscaling 组中 VM 的应用程序版本管理

Application version management for VM's in Azure Autoscaling group

目前,我有一个应用程序 运行 自动缩放 Azure VM。因此,假设我当前的应用程序版本,即 1.0 由 4 个虚拟机根据应用程序的当前负载提供服务。 现在,如果我有一个补丁更新并发布一个新版本的应用程序,即 2.0,那么这个新版本的应用程序将如何更新到当前 VM 的 运行? 如果负载增加,并且启动了新的 VM,他们都将拥有这个新版本的应用程序 2.0,但是之前的 运行 4 个 VM,他们会拥有这个新版本的应用程序吗?如果是,怎么做?

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

    $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