Skip to content

Commit 7c4a171

Browse files
committed
major updates to CLI doc
1 parent 306fbbc commit 7c4a171

File tree

3 files changed

+164
-43
lines changed

3 files changed

+164
-43
lines changed

articles/virtual-machines/maintenance-configurations-cli.md

Lines changed: 147 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,70 +15,98 @@ ms.author: cynthn
1515

1616
**Applies to:** :heavy_check_mark: Linux VMs :heavy_check_mark: Windows VMs :heavy_check_mark: Flexible scale sets :heavy_check_mark: Uniform scale sets
1717

18-
Maintenance Configurations lets you decide when to apply platform updates to various Azure resources. This topic covers the Azure CLI options for Dedicated Hosts and Isolated VMs. For more about benefits of using Maintenance Configurations, its limitations, and other management options, see [Managing platform updates with Maintenance Configurations](maintenance-configurations.md).
18+
Maintenance Configurations lets you decide when to apply platform updates to various Azure resources. This topic covers the Azure CLI options for using this service. For more about benefits of using Maintenance Configurations, its limitations, and other management options, see [Managing platform updates with Maintenance Configurations](maintenance-configurations.md).
1919

2020
> [!IMPORTANT]
2121
> There are different **scopes** which support certain machine types and schedules, so please ensure you are selecting the right scope for your virtual machine.
2222
2323
## Create a maintenance configuration
2424

25-
Use `az maintenance configuration create` to create a maintenance configuration. This example creates a maintenance configuration named *myConfig* scoped to the host.
25+
The first step to creating a maintenance configuration is creating a resource group as a container for your configuration. In this example, a resource group named *myMaintenanceRG* is created in *eastus*. If you already have a resource group that you want to use, you can skip this part and replace the resource group name with your own in the rest of the examples.
2626

2727
```azurecli-interactive
2828
az group create \
2929
--location eastus \
3030
--name myMaintenanceRG
31-
az maintenance configuration create \
32-
-g myMaintenanceRG \
33-
--resource-name myConfig \
34-
--maintenance-scope host\
35-
--location eastus
3631
```
3732

38-
Copy the configuration ID from the output to use later.
33+
After creating the resource group, use `az maintenance configuration create` to create a maintenance configuration.
34+
35+
### Host
3936

40-
Using `--maintenance-scope host` ensures that the maintenance configuration is used for controlling updates to the host infrastructure.
37+
This example creates a maintenance configuration named *myConfig* scoped to host machines with a scheduled window of 5 hours on the fourth Monday of every month.
4138

42-
If you try to create a configuration with the same name, but in a different location, you will get an error. Configuration names must be unique to your resource group.
39+
```azurecli-interactive
40+
az maintenance configuration create \
41+
--resource-group myMaintenanceRG \
42+
--resource-name myConfig \
43+
--maintenance-scope host \
44+
--location eastus \
45+
--maintenance-window-duration "05:00" \
46+
--maintenance-window-recur-every "Month Fourth Monday" \
47+
--maintenance-window-start-date-time "2020-12-30 08:00" \
48+
--maintenance-window-time-zone "Pacific Standard Time"
49+
```
50+
51+
Using `--maintenance-scope host` ensures that the maintenance configuration is used for controlling updates to the host infrastructure. If you try to create a configuration with the same name, but in a different location, you will get an error. Configuration names must be unique to your resource group.
4352

44-
You can query for available maintenance configurations using `az maintenance configuration list`.
53+
You can check if you have created the maintenance configuration successfully by querying for available maintenance configurations using `az maintenance configuration list`.
4554

4655
```azurecli-interactive
47-
az maintenance configuration list --query "[].{Name:name, ID:id}" -o table
56+
az maintenance configuration list
57+
--query "[].{Name:name, ID:id}"
58+
--output table
4859
```
4960

50-
### Create a maintenance configuration with scheduled window
51-
You can also declare a scheduled window when Azure will apply the updates on your resources. This example creates a maintenance configuration named myConfig with a scheduled window of 5 hours on the fourth Monday of every month. Once you create a scheduled window you no longer have to apply the updates manually.
61+
> [!NOTE]
62+
> Maintenance recurrence can be expressed as daily, weekly or monthly. Some examples are:
63+
> - **daily**- maintenance-window-recur-every: "Day" **or** "3Days"
64+
> - **weekly**- maintenance-window-recur-every: "3Weeks" **or** "Week Saturday,Sunday"
65+
> - **monthly**- maintenance-window-recur-every: "Month day23,day24" **or** "Month Last Sunday" **or** "Month Fourth Monday"
66+
67+
### Virtual Machine Scale Sets
68+
69+
This example creates a maintenance configuration named *myConfig* with the osimage scope for virtual machine scale sets with a scheduled window of 5 hours on the fourth Monday of every month.
5270

5371
```azurecli-interactive
5472
az maintenance configuration create \
55-
-g myMaintenanceRG \
73+
--resource-group myMaintenanceRG \
5674
--resource-name myConfig \
57-
--maintenance-scope host \
75+
--maintenance-scope osimage \
5876
--location eastus \
5977
--maintenance-window-duration "05:00" \
6078
--maintenance-window-recur-every "Month Fourth Monday" \
6179
--maintenance-window-start-date-time "2020-12-30 08:00" \
6280
--maintenance-window-time-zone "Pacific Standard Time"
6381
```
6482

65-
> [!IMPORTANT]
66-
> Maintenance **duration** must be *2 hours* or longer.
67-
83+
### Guest VMs
6884

69-
Maintenance recurrence can be expressed as daily, weekly or monthly. Some examples are:
70-
- **daily**- maintenance-window-recur-every: "Day" **or** "3Days"
71-
- **weekly**- maintenance-window-recur-every: "3Weeks" **or** "Week Saturday,Sunday"
72-
- **monthly**- maintenance-window-recur-every: "Month day23,day24" **or** "Month Last Sunday" **or** "Month Fourth Monday"
85+
This example creates a maintenance configuration named *myConfig* scoped to guest machines (VMs and Arc enabled servers) with a scheduled window of 2 hours every 20 days.
7386

87+
```azurecli-interactive
88+
az maintenance configuration create \
89+
--resource-group myMaintenanceRG \
90+
--resource-name myConfig \
91+
--maintenance-scope InGuestPatch \
92+
--location eastus
93+
--maintenance-window-duration "02:00"
94+
--maintenance-window-recur-every "20days"
95+
--maintenance-window-start-date-time "2022-12-30 07:00"
96+
--maintenance-window-time-zone "Pacific Standard Time"
97+
--install-patches-linux-parameters package-name-masks-to-exclude="ppt" package-name-masks-to-include="apt" classifications-to-include="Other"
98+
--install-patches-windows-parameters kb-numbers-to-exclude="KB123456" kb-numbers-to-include="KB123456" classifications-to-include="FeaturePack"
99+
--reboot-setting "IfRequired"
100+
--extension-properties InGuestPatchMode="User"
101+
```
74102

75103
## Assign the configuration
76104

77105
Use `az maintenance assignment create` to assign the configuration to your machine.
78106

79107
### Isolated VM
80108

81-
Apply the configuration to a VM using the ID of the configuration. Specify `--resource-type virtualMachines` and supply the name of the VM for `--resource-name`, and the resource group for to the VM in `--resource-group`, and the location of the VM for `--location`.
109+
Apply the configuration to an isolated host VM using the ID of the configuration. Specify `--resource-type virtualMachines` and supply the name of the VM for `--resource-name`, and the resource group for to the VM in `--resource-group`, and the location of the VM for `--location`.
82110

83111
```azurecli-interactive
84112
az maintenance assignment create \
@@ -88,7 +116,7 @@ az maintenance assignment create \
88116
--resource-type virtualMachines \
89117
--provider-name Microsoft.Compute \
90118
--configuration-assignment-name myConfig \
91-
--maintenance-configuration-id "/subscriptions/1111abcd-1a11-1a2b-1a12-123456789abc/resourcegroups/myMaintenanceRG/providers/Microsoft.Maintenance/maintenanceConfigurations/myConfig"
119+
--maintenance-configuration-id "/subscriptions/{subscription ID}/resourcegroups/myMaintenanceRG/providers/Microsoft.Maintenance/maintenanceConfigurations/myConfig"
92120
```
93121

94122
### Dedicated host
@@ -99,17 +127,43 @@ The parameter `--resource-id` is the ID of the host. You can use [az-vm-host-get
99127

100128
```azurecli-interactive
101129
az maintenance assignment create \
102-
-g myDHResourceGroup \
130+
--resource-group myDHResourceGroup \
103131
--resource-name myHost \
104132
--resource-type hosts \
105133
--provider-name Microsoft.Compute \
106134
--configuration-assignment-name myConfig \
107-
--maintenance-configuration-id "/subscriptions/1111abcd-1a11-1a2b-1a12-123456789abc/resourcegroups/myDhResourceGroup/providers/Microsoft.Maintenance/maintenanceConfigurations/myConfig" \
108-
-l eastus \
135+
--maintenance-configuration-id "/subscriptions/{subscription ID}/resourcegroups/myDhResourceGroup/providers/Microsoft.Maintenance/maintenanceConfigurations/myConfig" \
136+
--location eastus \
109137
--resource-parent-name myHostGroup \
110138
--resource-parent-type hostGroups
111139
```
112140

141+
### Virtual Machine Scale Sets
142+
143+
```azurecli-interactive
144+
az maintenance assignment create \
145+
--resource-group myMaintenanceRG \
146+
--location eastus \
147+
--resource-name myVMSS \
148+
--resource-type virtualMachineScaleSets \
149+
--provider-name Microsoft.Compute \
150+
--configuration-assignment-name myConfig \
151+
--maintenance-configuration-id "/subscriptions/{subscription ID}/resourcegroups/myMaintenanceRG/providers/Microsoft.Maintenance/maintenanceConfigurations/myConfig"
152+
```
153+
154+
### Guest VMs
155+
156+
```azurecli-interactive
157+
az maintenance assignment create \
158+
--resource-group myMaintenanceRG \
159+
--location eastus \
160+
--resource-name myVM \
161+
--resource-type virtualMachines \
162+
--provider-name Microsoft.Compute \
163+
--configuration-assignment-name myConfig \
164+
--maintenance-configuration-id "/subscriptions/{subscription ID}/resourcegroups/myMaintenanceRG/providers/Microsoft.Maintenance/maintenanceConfigurations/myConfig"
165+
```
166+
113167
## Check configuration
114168

115169
You can verify that the configuration was applied correctly, or check to see what configuration is currently applied using `az maintenance assignment list`.
@@ -137,9 +191,32 @@ az maintenance assignment list \
137191
--resource-parent-name myHostGroup \
138192
--resource-parent-type hostGroups
139193
--query "[].{ResourceGroup:resourceGroup,configName:name}" \
140-
-o table
194+
--output table
195+
```
196+
197+
### Virtual Machine Scale Sets
198+
199+
```azurecli-interactive
200+
az maintenance assignment list \
201+
--provider-name Microsoft.Compute \
202+
--resource-group myMaintenanceRG \
203+
--resource-name myVMSS \
204+
--resource-type virtualMachines \
205+
--query "[].{resource:resourceGroup, configName:name}" \
206+
--output table
141207
```
142208

209+
### Guest VMs
210+
211+
```azurecli-interactive
212+
az maintenance assignment list \
213+
--provider-name Microsoft.Compute \
214+
--resource-group myMaintenanceRG \
215+
--resource-name myVM \
216+
--resource-type virtualMachines \
217+
--query "[].{resource:resourceGroup, configName:name}" \
218+
--output table
219+
```
143220

144221
## Check for pending updates
145222

@@ -168,11 +245,12 @@ Check for pending updates for an isolated VM. In this example, the output is for
168245

169246
```azurecli-interactive
170247
az maintenance update list \
171-
-g myMaintenanceRg \
248+
--subscription {subscription ID} \
249+
--resourcegroup myMaintenanceRg \
172250
--resource-name myVM \
173251
--resource-type virtualMachines \
174252
--provider-name Microsoft.Compute \
175-
-o table
253+
--output table
176254
```
177255

178256
### Dedicated host
@@ -181,27 +259,27 @@ To check for pending updates for a dedicated host. In this example, the output i
181259

182260
```azurecli-interactive
183261
az maintenance update list \
184-
--subscription 1111abcd-1a11-1a2b-1a12-123456789abc \
185-
-g myHostResourceGroup \
262+
--subscription {subscription ID} \
263+
--resourcegroup myHostResourceGroup \
186264
--resource-name myHost \
187265
--resource-type hosts \
188266
--provider-name Microsoft.Compute \
189267
--resource-parentname myHostGroup \
190268
--resource-parent-type hostGroups \
191-
-o table
269+
--output table
192270
```
193271

194272
## Apply updates
195273

196-
Use `az maintenance apply update` to apply pending updates. On success, this command will return JSON containing the details of the update. Apply update calls can take upto 2 hours to complete.
274+
Use `az maintenance apply update` to apply pending updates. On success, this command will return JSON containing the details of the update. Apply update calls can take up to 2 hours to complete.
197275

198276
### Isolated VM
199277

200278
Create a request to apply updates to an isolated VM.
201279

202280
```azurecli-interactive
203281
az maintenance applyupdate create \
204-
--subscription 1111abcd-1a11-1a2b-1a12-123456789abc \
282+
--subscription {subscriptionID} \
205283
--resource-group myMaintenanceRG \
206284
--resource-name myVM \
207285
--resource-type virtualMachines \
@@ -215,7 +293,7 @@ Apply updates to a dedicated host.
215293

216294
```azurecli-interactive
217295
az maintenance applyupdate create \
218-
--subscription 1111abcd-1a11-1a2b-1a12-123456789abc \
296+
--subscription {subscriptionID} \
219297
--resource-group myHostResourceGroup \
220298
--resource-name myHost \
221299
--resource-type hosts \
@@ -224,6 +302,19 @@ az maintenance applyupdate create \
224302
--resource-parent-type hostGroups
225303
```
226304

305+
### Virtual Machine Scale Sets
306+
307+
Apply update to a scale set
308+
309+
```azurecli-interactive
310+
az maintenance applyupdate create \
311+
--subscription {subscriptionID} \
312+
--resource-group myMaintenanceRG \
313+
--resource-name myVMSS \
314+
--resource-type virtualMachineScaleSets \
315+
--provider-name Microsoft.Compute
316+
```
317+
227318
## Check the status of applying updates
228319

229320
You can check on the progress of the updates using `az maintenance applyupdate get`.
@@ -246,18 +337,21 @@ LastUpdateTime will be the time when the update got complete, either initiated b
246337

247338
```azurecli-interactive
248339
az maintenance applyupdate get \
340+
--subscription {subscriptionID} \
249341
--resource-group myMaintenanceRG \
250342
--resource-name myVM \
251343
--resource-type virtualMachines \
252344
--provider-name Microsoft.Compute \
253-
--apply-update-name default
345+
--apply-update-name myUpdateName \
346+
--query "{LastUpdate:lastUpdateTime, Name:name, ResourceGroup:resourceGroup, Status:status}" \
347+
--output table
254348
```
255349

256350
### Dedicated host
257351

258352
```azurecli-interactive
259353
az maintenance applyupdate get \
260-
--subscription 1111abcd-1a11-1a2b-1a12-123456789abc \
354+
--subscription {subscriptionID} \
261355
--resource-group myMaintenanceRG \
262356
--resource-name myHost \
263357
--resource-type hosts \
@@ -269,6 +363,19 @@ az maintenance applyupdate get \
269363
--output table
270364
```
271365

366+
### Virtual Machine Scale Sets
367+
368+
```azurecli-interactive
369+
az maintenance applyupdate get \
370+
--subscription {subscriptionID} \
371+
--resource-group myMaintenanceRG \
372+
--resource-name myVMSS \
373+
--resource-type virtualMachineScaleSets \
374+
--provider-name Microsoft.Compute \
375+
--apply-update-name myUpdateName \
376+
--query "{LastUpdate:lastUpdateTime, Name:name, ResourceGroup:resourceGroup, Status:status}" \
377+
--output table
378+
```
272379

273380
## Delete a maintenance configuration
274381

@@ -277,7 +384,7 @@ Use `az maintenance configuration delete` to delete a maintenance configuration.
277384
```azurecli-interactive
278385
az maintenance configuration delete \
279386
--subscription 1111abcd-1a11-1a2b-1a12-123456789abc \
280-
-g myResourceGroup \
387+
-resource-group myResourceGroup \
281388
--resource-name myConfig
282389
```
283390

articles/virtual-machines/maintenance-configurations-powershell.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ You may also be asked to confirm that you want to install from an *untrusted rep
5555

5656
## Create a maintenance configuration
5757

58-
Create a resource group as a container for your configuration. In this example, a resource group named *myMaintenanceRG* is created in *eastus*. If you already have a resource group that you want to use, you can skip this part and replace the resource group name with your own in the rest of the examples.
58+
The first step to creating a maintenance configuration is creating a resource group as a container for your configuration. In this example, a resource group named *myMaintenanceRG* is created in *eastus*. If you already have a resource group that you want to use, you can skip this part and replace the resource group name with your own in the rest of the examples.
5959

6060
```azurepowershell-interactive
6161
New-AzResourceGroup `
@@ -188,7 +188,7 @@ After you have created your configuration, you might want to also assign machine
188188

189189
### Isolated VM
190190

191-
Apply the configuration to a VM using the ID of the configuration. Specify `-ResourceType VirtualMachines` and supply the name of the VM for `-ResourceName`, and the resource group of the VM for `-ResourceGroupName`.
191+
Assign the configuration to a VM using the ID of the configuration. Specify `-ResourceType VirtualMachines` and supply the name of the VM for `-ResourceName`, and the resource group of the VM for `-ResourceGroupName`.
192192

193193
```azurepowershell-interactive
194194
New-AzConfigurationAssignment `
@@ -231,6 +231,20 @@ New-AzConfigurationAssignment `
231231
-MaintenanceConfigurationId "configID"
232232
```
233233

234+
235+
### Guest
236+
237+
```azurepowershell-interactive
238+
New-AzConfigurationAssignment `
239+
-ResourceGroupName "myResourceGroup" `
240+
-Location "eastus" `
241+
-ResourceName "myGuest" `
242+
-ResourceType "VirtualMachines" `
243+
-ProviderName "Microsoft.Compute" `
244+
-ConfigurationAssignmentName "configName" `
245+
-MaintenanceConfigurationId "configID"
246+
```
247+
234248
## Check for pending updates
235249

236250
Use [Get-AzMaintenanceUpdate](/powershell/module/az.maintenance/get-azmaintenanceupdate) to see if there are pending updates. Use `-subscription` to specify the Azure subscription of the VM if it is different from the one that you are logged into.

articles/virtual-machines/maintenance-configurations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ms.author: cynthn
1818
Maintenance Configurations gives you the ability to control and manage updates for many Azure virtual machine resources since Azure frequently updates its infrastructure to improve reliability, performance, security or launch new features. Most updates are transparent to users, but some sensitive workloads, like gaming, media streaming, and financial transactions, can't tolerate even few seconds of a VM freezing or disconnecting for maintenance. Maintenance Configurations is integrated with Azure Resource Graph (ARG) for low latency and high scale customer experience.
1919

2020
>[!IMPORTANT]
21-
> Users are required to have a role of at least contributor in order to use maintenance configurations.
21+
> Users are required to have a role of at least contributor in order to use maintenance configurations. Users also have to ensure that their subscription is registered with Maintenance Resource Provider to use maintenance configurations.
2222
2323
## Scopes
2424

0 commit comments

Comments
 (0)