适用于: ✔️ Windows VMs ✔️ Linux VMs ✔️ Azure VMs.
本文概述了如何使用新的先决条件在 Azure VM 上配置计划修补和自动来宾虚拟机 (VM) 修补,从而确保业务连续性。 在 Azure Arc 虚拟机上配置这两个修补选项的步骤保持不变。
目前,可以通过在 Azure 门户中将修补模式设置为“Azure 协调”或在 REST API 中设置为“AutomaticByPlatform”来启用自动来宾 VM 修补(自动修补),系统会在非高峰时段自动应用补丁。
在某些情况下,从 VM 中删除计划时,可能会自动修补并重新启动 VM。 为了克服这些限制,我们引入了新的先决条件(ByPassPlatformSafetyChecksOnUserSchedule
),现在可以将其设置为 true
,以便使用计划修补来标识 VM。 这意味着,如果 VM 没有关联的维护配置,则此属性设置为 true
的 VM 将不再自动修补。
重要
为获得持续的计划修补体验,必须确保在 2023 年 6 月 30 日之前,在附加了计划的 Azure VM(现有或新的)上启用新的 VM 属性“BypassPlatformSafetyChecksOnUserSchedule
”。 此设置可确保使用配置的计划修补计算机,而不是自动修补。 如果未能在 2023 年 6 月 30 日之前启用,系统会显示不符合先决条件的错误。
在可用性集中计划修补
公用可用性集中的所有 VM 都不会并发更新。
通用可用性集中的 VM 会在更新域边界内更新。 跨多个更新域的 VM 不会并发更新。
如果同一可用性集中的计算机在不同计划中设置了在同一时间进行修补,则可能不会修补这些计算机,或者如果超出维护时段,修补可能会失败。 为了避免出现这种情况,我们建议你增加维护时段,或者将同一可用性集中的计算机拆分到不同时段的多个计划中。
查找具有关联计划的 VM
若要标识具有要为其启用新 VM 属性的关联计划的 VM 列表:
请转到 Azure 更新管理器主页,然后选择“计算机”选项卡。
在“修补业务流程”筛选器中,选择“Azure 托管 - 安全部署”。
使用“选择所有”选项选择计算机,然后选择“导出到 CSV”。
打开 CSV 文件,并在“关联计划”列中,选择具有条目的行。
在相应的“名称”列中,可以查看需要启用 ByPassPlatformSafetyChecksOnUserSchedule
标志的 VM 列表。
在 Azure VM 上启用计划修补
要在 Azure VM 上启用计划修补,请执行以下步骤。
先决条件
修补业务流程 =“客户托管计划”
选择修补业务流程选项作为“客户托管计划”。 新的修补业务流程选项在收到你的同意后代表你启用以下 VM 属性:
- 修补模式 =
Azure-orchestrated
BypassPlatformSafetyChecksOnUserSchedule
= TRUE
为新 VM 启用
可以为与计划关联的新 VM 选择修补业务流程选项。
若要更新修补模式,请执行以下操作:
- 登录 Azure 门户。
- 转到“虚拟机”并选择“创建”以打开“创建虚拟机”页。
- 在“基本信息”选项卡上,填写所有必填字段。
- 在“管理”选项卡上的“来宾 OS 更新”下,为“修补业务流程选项”选择“Azure 协调”。
- 填写“监视”、“高级”和“标记”选项卡上的条目。
- 选择“查看 + 创建” 。 选择“创建”,以使用适当的修补业务流程选项创建新 VM。
若要计划修补新创建的 VM,请按照下一部分中步骤 2 中的过程操作,“为现有 VM 启用”。
为现有 VM 启用
可以为已关联计划或将关联计划的现有 VM 更新修补业务流程选项。
如果“修补业务流程”设置为“Azure 协调” 或“Azure 托管 - 安全部署 (AutomaticByPlatform)”,BypassPlatformSafetyChecksOnUserSchedule
设置为 false
,并且没有关联的计划,则 VM 将自动修补。
若要更新修补模式,请执行以下操作:
- 登录 Azure 门户。
- 转到 Azure 更新管理器并选择“更新设置”。
- 在“更改更新设置”中,选择“添加计算机”。
- 在“选择资源”中,选择 VM,然后选择“添加”。
- 在“更改更新设置”窗格的“修补业务流程”下,选择“客户托管的计划”,然后选择“保存”。
完成上述步骤后附加计划。
若要检查是否启用了 BypassPlatformSafetyChecksOnUserSchedule
,请转到“虚拟机”主页并选择“概述”>“JSON 视图”。
先决条件
- 修补模式 =
AutomaticByPlatform
BypassPlatformSafetyChecksOnUserSchedule
= TRUE
在 Windows VM 上启用
PATCH on `/subscriptions/subscription_id/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVirtualMachine?api-version=2023-03-01`
{
"location":"<location>",
"properties": {
"osProfile": {
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true,
"patchSettings": {
"patchMode": "AutomaticByPlatform",
"automaticByPlatformSettings":{
"bypassPlatformSafetyChecksOnUserSchedule":true
}
}
}
}
}
}
在 Linux VM 上启用
PATCH on `/subscriptions/subscription_id/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVirtualMachine?api-version=2023-03-01`
{
"location":"<location>",
"properties": {
"osProfile": {
"linuxConfiguration": {
"provisionVMAgent": true,
"patchSettings": {
"patchMode": "AutomaticByPlatform",
"automaticByPlatformSettings":{
"bypassPlatformSafetyChecksOnUserSchedule":true
}
}
}
}
}
}
先决条件
- 修补模式 =
AutomaticByPlatform
BypassPlatformSafetyChecksOnUserSchedule
= TRUE
在 Windows VM 上启用
$VirtualMachine = Get-AzVM -ResourceGroupName "<resourceGroup>" -Name "<vmName>"
Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -PatchMode "AutomaticByPlatform"
$AutomaticByPlatformSettings = $VirtualMachine.OSProfile.WindowsConfiguration.PatchSettings.AutomaticByPlatformSettings
if ($null -eq $AutomaticByPlatformSettings) {
$VirtualMachine.OSProfile.WindowsConfiguration.PatchSettings.AutomaticByPlatformSettings = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.WindowsVMGuestPatchAutomaticByPlatformSettings -Property @{BypassPlatformSafetyChecksOnUserSchedule = $true}
} else {
$AutomaticByPlatformSettings.BypassPlatformSafetyChecksOnUserSchedule = $true
}
Update-AzVM -VM $VirtualMachine -ResourceGroupName "<resourceGroup>"
在 Linux VM 上启用
$VirtualMachine = Get-AzVM -ResourceGroupName "<resourceGroup>" -Name "<vmName>"
Set-AzVMOperatingSystem -VM $VirtualMachine -Linux -PatchMode "AutomaticByPlatform"
$AutomaticByPlatformSettings = $VirtualMachine.OSProfile.LinuxConfiguration.PatchSettings.AutomaticByPlatformSettings
if ($null -eq $AutomaticByPlatformSettings) {
$VirtualMachine.OSProfile.LinuxConfiguration.PatchSettings.AutomaticByPlatformSettings = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.LinuxVMGuestPatchAutomaticByPlatformSettings -Property @{BypassPlatformSafetyChecksOnUserSchedule = $true}
} else {
$AutomaticByPlatformSettings.BypassPlatformSafetyChecksOnUserSchedule = $true
}
Update-AzVM -VM $VirtualMachine -ResourceGroupName "<resourceGroup>"
注意
现在可以启用通过 Azure 门户、REST API、PowerShell 和 Azure CLI 进行计划修补的新先决条件。
在 Azure VM 上启用自动来宾 VM 修补
若要立即在 Azure VM 上启用自动来宾 VM 修补,请执行以下步骤。
先决条件
修补模式 = Azure-orchestrated
为新 VM 启用
可以为与计划关联的新 VM 选择修补业务流程选项。
若要更新修补模式,请执行以下操作:
- 登录 Azure 门户。
- 转到“虚拟机”并选择“创建”以打开“创建虚拟机”页。
- 在“基本信息”选项卡上,填写所有必填字段。
- 在“管理”选项卡上的“来宾 OS 更新”下,为“修补业务流程选项”选择“Azure 协调”。
- 填写“监视”、“高级”和“标记”选项卡上的条目。
- 选择“查看 + 创建” 。 选择“创建”,以使用适当的修补业务流程选项创建新 VM。
为现有 VM 启用
若要更新修补模式,请执行以下操作:
- 登录 Azure 门户。
- 转到更新管理器并选择“更新设置”。
- 在“更改更新设置”窗格中,选择“添加计算机”。
- 在“选择资源”窗格中,选择 VM,然后选择“添加”。
- 在“更改更新设置”窗格的“修补业务流程”下,选择“Azure 托管 - 安全部署”,然后选择“保存”。
先决条件
- 修补模式 =
AutomaticByPlatform
BypassPlatformSafetyChecksOnUserSchedule
= FALSE
在 Windows VM 上启用
PATCH on `/subscriptions/subscription_id/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVirtualMachine?api-version=2023-03-01`
{
"location":"<location>",
"properties": {
"osProfile": {
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true,
"patchSettings": {
"patchMode": "AutomaticByPlatform",
"automaticByPlatformSettings":{
"bypassPlatformSafetyChecksOnUserSchedule":false
}
}
}
}
}
}
在 Linux VM 上启用
PATCH on `/subscriptions/subscription_id/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVirtualMachine?api-version=2023-03-01`
{
"location":"<location>",
"properties": {
"osProfile": {
"linuxConfiguration": {
"provisionVMAgent": true,
"patchSettings": {
"patchMode": "AutomaticByPlatform",
"automaticByPlatformSettings":{
"bypassPlatformSafetyChecksOnUserSchedule":false
}
}
}
}
}
}
用户方案
方案 |
Azure 安排 |
BypassPlatformSafetyChecksOnUserSchedule |
关联的计划 |
Azure 中的意外行为 |
方案 1 |
是 |
True |
是 |
计划修补程序按用户定义的运行。 |
方案 2 |
是 |
True |
否 |
自动修补和计划修补程序没有运行。 |
方案 3 |
是 |
False |
是 |
自动修补和计划修补程序没有运行。 你会收到一个错误,指出未满足计划修补程序的先决条件。 |
方案 4 |
是 |
False |
否 |
VM 已自动修补。 |
方案 5 |
否 |
True |
是 |
自动修补和计划修补程序没有运行。 你会收到一个错误,指出未满足计划修补程序的先决条件。 |
方案 6 |
否 |
True |
否 |
自动修补和计划修补程序没有运行。 |
方案 7 |
否 |
False |
是 |
自动修补和计划修补程序没有运行。 你会收到一个错误,指出未满足计划修补程序的先决条件。 |
方案 8 |
否 |
False |
否 |
自动修补和计划修补程序没有运行。 |
后续步骤