|
2 | 2 | title: Configure schedule patching on Azure VMs for business continuity
|
3 | 3 | description: The article describes the new prerequisites to configure scheduled patching to ensure business continuity in Azure Update Manager.
|
4 | 4 | ms.service: azure-update-manager
|
5 |
| -ms.date: 09/18/2023 |
| 5 | +ms.date: 01/17/2024 |
6 | 6 | ms.topic: conceptual
|
7 | 7 | author: snehasudhirG
|
8 | 8 | ms.author: sudhirsneha
|
@@ -147,10 +147,47 @@ PATCH on `/subscriptions/subscription_id/resourceGroups/myResourceGroup/provider
|
147 | 147 | }
|
148 | 148 | }
|
149 | 149 | ```
|
| 150 | +# [PowerShell](#tab/new-prereq-powershell) |
| 151 | + |
| 152 | +## Prerequisites |
| 153 | + |
| 154 | +- Patch mode = `AutomaticByPlatform` |
| 155 | +- `BypassPlatformSafetyChecksOnUserSchedule` = TRUE |
| 156 | + |
| 157 | +### Enable on Windows VMs |
| 158 | + |
| 159 | +```powershell-interactive |
| 160 | +$VirtualMachine = Get-AzVM -ResourceGroupName "<resourceGroup>" -Name "<vmName>" |
| 161 | +Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -PatchMode "AutomaticByPlatform" |
| 162 | +$AutomaticByPlatformSettings = $VirtualMachine.OSProfile.WindowsConfiguration.PatchSettings.AutomaticByPlatformSettings |
| 163 | + |
| 164 | +if ($null -eq $AutomaticByPlatformSettings) { |
| 165 | + $VirtualMachine.OSProfile.WindowsConfiguration.PatchSettings.AutomaticByPlatformSettings = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.WindowsVMGuestPatchAutomaticByPlatformSettings -Property @{BypassPlatformSafetyChecksOnUserSchedule = $true} |
| 166 | +} else { |
| 167 | + $AutomaticByPlatformSettings.BypassPlatformSafetyChecksOnUserSchedule = $true |
| 168 | +} |
| 169 | + |
| 170 | +Update-AzVM -VM $VirtualMachine -ResourceGroupName "<resourceGroup>" |
| 171 | +``` |
| 172 | +### Enable on Linux VMs |
| 173 | + |
| 174 | +```powershell-interactive |
| 175 | +$VirtualMachine = Get-AzVM -ResourceGroupName "<resourceGroup>" -Name "<vmName>" |
| 176 | +Set-AzVMOperatingSystem -VM $VirtualMachine -Linux -PatchMode "AutomaticByPlatform" |
| 177 | +$AutomaticByPlatformSettings = $VirtualMachine.OSProfile.LinuxConfiguration.PatchSettings.AutomaticByPlatformSettings |
| 178 | + |
| 179 | +if ($null -eq $AutomaticByPlatformSettings) { |
| 180 | + $VirtualMachine.OSProfile.LinuxConfiguration.PatchSettings.AutomaticByPlatformSettings = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.LinuxVMGuestPatchAutomaticByPlatformSettings -Property @{BypassPlatformSafetyChecksOnUserSchedule = $true} |
| 181 | +} else { |
| 182 | + $AutomaticByPlatformSettings.BypassPlatformSafetyChecksOnUserSchedule = $true |
| 183 | +} |
| 184 | + |
| 185 | +Update-AzVM -VM $VirtualMachine -ResourceGroupName "<resourceGroup>" |
| 186 | +``` |
150 | 187 | ---
|
151 | 188 |
|
152 | 189 | > [!NOTE]
|
153 |
| -> Currently, you can only enable the new prerequisite for schedule patching via the Azure portal and the REST API. It can't be enabled via the Azure CLI or PowerShell. |
| 190 | +> Currently, you can only enable the new prerequisite for schedule patching via the Azure portal, REST API, and PowerShell. It can't be enabled via the Azure CLI. |
154 | 191 |
|
155 | 192 | ## Enable automatic guest VM patching on Azure VMs
|
156 | 193 |
|
|
0 commit comments