Virtual Machines - Install Patches
在虚拟机上安装修补程序。
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches?api-version=2025-04-01URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 | 
|---|---|---|---|---|
| resource | path | True | stringminLength: 1 maxLength: 90 | 资源组的名称。 此名称不区分大小写。 | 
| subscription | path | True | stringminLength: 1 | 目标订阅的 ID。 | 
| vm | path | True | string | 虚拟机的名称。 | 
| api-version | query | True | stringminLength: 1 | 要用于此操作的 API 版本。 | 
请求正文
| 名称 | 必需 | 类型 | 说明 | 
|---|---|---|---|
| rebootSetting | True | 定义在软件更新作期间重新启动 VM 是可以接受的。 | |
| linuxParameters | Linux VM 上 InstallPatches 的输入,由 API 直接接收 | ||
| maximumDuration | string (duration) | 指定作将运行的最大时间量。 它必须是符合 ISO 8601 的持续时间字符串,如 PT4H(4 小时) | |
| windowsParameters | Windows VM 上 InstallPatches 的输入,由 API 直接接收 | 
响应
| 名称 | 类型 | 说明 | 
|---|---|---|
| 200 OK | Azure作已成功完成。 | |
| 202 Accepted | 已接受资源作。 标头 
 | |
| Other Status Codes | 意外错误响应。 | 
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
					类型: 
					oauth2
					流向: 
					implicit
					授权 URL: 
					https://login.microsoftonline.com/common/oauth2/authorize
			
作用域
| 名称 | 说明 | 
|---|---|
| user_impersonation | 模拟用户帐户 | 
示例
Install patch state of a virtual machine.
示例请求
POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myVMName/installPatches?api-version=2025-04-01
{
  "maximumDuration": "PT4H",
  "rebootSetting": "IfRequired",
  "windowsParameters": {
    "classificationsToInclude": [
      "Critical",
      "Security"
    ],
    "maxPatchPublishDate": "2020-11-19T02:36:43.0539904+00:00",
    "patchNameMasksToInclude": [
      "*SQL*"
    ],
    "patchNameMasksToExclude": [
      "*Windows*"
    ]
  }
}
示例响应
{
  "status": "Succeeded",
  "installationActivityId": "68f8b292-dfc2-4646-9781-33cc88631968",
  "rebootStatus": "Completed",
  "maintenanceWindowExceeded": false,
  "excludedPatchCount": 0,
  "notSelectedPatchCount": 0,
  "pendingPatchCount": 2,
  "installedPatchCount": 3,
  "failedPatchCount": 0,
  "startDateTime": "2020-04-24T21:02:04.2556154Z",
  "patches": [
    {
      "patchId": "35428702-5784-4ba4-a6e0-5222258b5411",
      "name": "Definition Update for Windows Defender Antivirus - KB2267602 (Definition 1.279.1373.0)",
      "version": "",
      "kbId": "2267602",
      "classifications": [
        "Definition Updates"
      ],
      "installationState": "Installed"
    },
    {
      "patchId": "39f9cdd1-795c-4d0e-8c0a-73ab3f31746d",
      "name": "Windows Malicious Software Removal Tool x64 - October 2018 (KB890830)",
      "version": "",
      "kbId": "890830",
      "classifications": [
        "Update Rollups"
      ],
      "installationState": "Pending"
    }
  ],
  "error": null
}Location: https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/westus/operations/{operationId}&monitor=true&api-version=2025-04-01定义
| 名称 | 说明 | 
|---|---|
| Api | API 错误。 | 
| Api | Api 错误库。 | 
| Cloud | 来自计算服务的错误响应。 | 
| Inner | 内部错误详细信息。 | 
| Linux | Linux VM 上 InstallPatches 的输入,由 API 直接接收 | 
| Patch | 有关安装作期间遇到的特定修补程序的信息。 | 
| Patch | 安装作完成后的修补程序状态。 | 
| Patch | 作的总体成功或失败状态。 在作完成之前,它将保持“InProgress”状态。 此时,它将变为“未知”、“失败”、“成功”或“CompletedWithWarnings”。 | 
| Virtual | API 直接接收的 InstallPatches 的输入 | 
| Virtual | 安装作的结果摘要。 | 
| VMGuest | |
| VMGuest | |
| VMGuest | 定义在软件更新作期间重新启动 VM 是可以接受的。 | 
| VMGuest | 完成作后虚拟机的重新启动状态。 | 
| Windows | Windows VM 上 InstallPatches 的输入,由 API 直接接收 | 
ApiError 
			
			API 错误。
| 名称 | 类型 | 说明 | 
|---|---|---|
| code | string | 错误代码。 | 
| details | Api 错误详细信息 | |
| innererror | Api 内部错误 | |
| message | string | 错误消息。 | 
| target | string | 特定错误的目标。 | 
ApiErrorBase  
			
			Api 错误库。
| 名称 | 类型 | 说明 | 
|---|---|---|
| code | string | 错误代码。 | 
| message | string | 错误消息。 | 
| target | string | 特定错误的目标。 | 
CloudError 
			
			来自计算服务的错误响应。
| 名称 | 类型 | 说明 | 
|---|---|---|
| error | API 错误。 | 
InnerError 
			
			内部错误详细信息。
| 名称 | 类型 | 说明 | 
|---|---|---|
| errordetail | string | 内部错误消息或异常转储。 | 
| exceptiontype | string | 异常类型。 | 
LinuxParameters 
			
			Linux VM 上 InstallPatches 的输入,由 API 直接接收
| 名称 | 类型 | 说明 | 
|---|---|---|
| classificationsToInclude | 安装 Linux 修补程序时要选择的更新分类。 | |
| maintenanceRunId | string | 这用作 Linux 中自动虚拟机客户机修补的维护运行标识符。 | 
| packageNameMasksToExclude | string[] | 要排除在修补程序作中的包。 格式:packageName_packageVersion | 
| packageNameMasksToInclude | string[] | 要包含在修补作中的包。 格式:packageName_packageVersion | 
PatchInstallationDetail  
			
			有关安装作期间遇到的特定修补程序的信息。
| 名称 | 类型 | 说明 | 
|---|---|---|
| classifications | string[] | 修补程序发布者提供的修补程序的分类。 | 
| installationState | 安装作完成后的修补程序状态。 | |
| kbId | string | 修补程序的 KBID。 仅适用于 Windows 补丁。 | 
| name | string | 修补程序的友好名称。 | 
| patchId | string | 修补程序的唯一标识符。 | 
| version | string | 包的版本字符串。 它可能符合语义版本控制。 仅适用于 Linux。 | 
PatchInstallationState  
			
			安装作完成后的修补程序状态。
| 值 | 说明 | 
|---|---|
| Unknown | |
| Installed | |
| Failed | |
| Excluded | |
| NotSelected | |
| Pending | 
PatchOperationStatus  
			
			作的总体成功或失败状态。 在作完成之前,它将保持“InProgress”状态。 此时,它将变为“未知”、“失败”、“成功”或“CompletedWithWarnings”。
| 值 | 说明 | 
|---|---|
| Unknown | |
| InProgress | |
| Failed | |
| Succeeded | |
| CompletedWithWarnings | 
VirtualMachineInstallPatchesParameters    
			
			API 直接接收的 InstallPatches 的输入
| 名称 | 类型 | 说明 | 
|---|---|---|
| linuxParameters | Linux VM 上 InstallPatches 的输入,由 API 直接接收 | |
| maximumDuration | string (duration) | 指定作将运行的最大时间量。 它必须是符合 ISO 8601 的持续时间字符串,如 PT4H(4 小时) | 
| rebootSetting | 定义在软件更新作期间重新启动 VM 是可以接受的。 | |
| windowsParameters | Windows VM 上 InstallPatches 的输入,由 API 直接接收 | 
VirtualMachineInstallPatchesResult    
			
			安装作的结果摘要。
| 名称 | 类型 | 说明 | 
|---|---|---|
| error | 执行作期间遇到的错误。 details 数组包含它们的列表。 | |
| excludedPatchCount | integer (int32) | 由于用户阻止其安装而未安装的修补程序数。 | 
| failedPatchCount | integer (int32) | 由于某些问题而无法安装的修补程序数。 有关详细信息,请参阅错误。 | 
| installationActivityId | string | 生成此结果的作的活动 ID。 它用于跨 CRP 和扩展日志进行关联。 | 
| installedPatchCount | integer (int32) | 成功安装的修补程序数。 | 
| maintenanceWindowExceeded | boolean | 作在完成所有预期作之前是否已用完时间。 | 
| notSelectedPatchCount | integer (int32) | 检测到可用于安装但不符合作条件的修补程序数。 | 
| patches | 作期间安装的修补程序。 | |
| pendingPatchCount | integer (int32) | 被标识为满足安装条件但无法安装的修补程序数。 通常,当 maintenanceWindowExceeded == true 时会发生这种情况。 | 
| rebootStatus | 完成作后虚拟机的重新启动状态。 | |
| startDateTime | string (date-time) | 作开始时的 UTC 时间戳。 | 
| status | 作的总体成功或失败状态。 在作完成之前,它将保持“InProgress”状态。 此时,它将变为“失败”、“成功”、“未知”或“CompletedWithWarnings”。 | 
VMGuestPatchClassificationLinux   
			
			
				| 值 | 说明 | 
|---|---|
| Critical | |
| Security | |
| Other | 
VMGuestPatchClassificationWindows   
			
			
				| 值 | 说明 | 
|---|---|
| Critical | |
| Security | |
| UpdateRollUp | |
| FeaturePack | |
| ServicePack | |
| Definition | |
| Tools | |
| Updates | 
VMGuestPatchRebootSetting   
			
			定义在软件更新作期间重新启动 VM 是可以接受的。
| 值 | 说明 | 
|---|---|
| IfRequired | |
| Never | |
| Always | 
VMGuestPatchRebootStatus   
			
			完成作后虚拟机的重新启动状态。
| 值 | 说明 | 
|---|---|
| Unknown | |
| NotNeeded | |
| Required | |
| Started | |
| Failed | |
| Completed | 
WindowsParameters 
			
			Windows VM 上 InstallPatches 的输入,由 API 直接接收
| 名称 | 类型 | 说明 | 
|---|---|---|
| classificationsToInclude | 安装 Windows 修补程序时要选择的更新分类。 | |
| excludeKbsRequiringReboot | boolean | 筛选掉在设置为 true 时没有“NeverReboots”的 InstallationRebootBehavior 的 Kbs。 | 
| kbNumbersToExclude | string[] | 在修补作中要排除的 Kbs | 
| kbNumbersToInclude | string[] | 要包含在修补作中的 Kbs | 
| maxPatchPublishDate | string (date-time) | 它用于安装此给定最晚发布日期或之前发布的修补程序。 | 
| patchNameMasksToExclude | string[] | 这用于排除与给定修补程序名称掩码匹配的修补程序。 字母数字字符串和通配符表达式,由 * 和 ? 仅支持作为列表中的输入值。 不支持空、空和仅空格字符串作为输入值。 | 
| patchNameMasksToInclude | string[] | 这用于包括与给定补丁名称掩码匹配的补丁。 字母数字字符串和通配符表达式,由 * 和 ? 仅支持作为列表中的输入值。 不支持空、空和仅空格字符串作为输入值。 |