Maintenance control for OS image upgrades on Azure Virtual Machine Scale Sets using an ARM template
Maintenance control lets you decide when to apply automatic OS image upgrades to your Virtual Machine Scale Sets. For more information on using Maintenance control, see Maintenance control for Azure Virtual Machine Scale Sets.
This article explains how you can use an Azure Resource Manager (ARM) template to create a maintenance configuration. You will learn how to:
- Create the configuration
- Assign the configuration to a virtual machine
An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.
Create the configuration
While creating the configuration, it is important to note that there are different scopes and each will have unique properties in their creation template. Make sure you are using the right one.
For more information about this Maintenance Configuration template, see maintenanceConfigurations.
Host and OS image
{
"type": "Microsoft.Maintenance/maintenanceConfigurations",
"apiVersion": "2021-09-01-preview",
"name": "string",
"location": "string",
"tags": {
"tagName1": "tagValue1",
"tagName2": "tagValue2"
},
"properties": {
"extensionProperties": {},
"installPatches": {
"linuxParameters": {
"classificationsToInclude": [ "string" ],
"packageNameMasksToExclude": [ "string" ],
"packageNameMasksToInclude": [ "string" ]
},
"rebootSetting": "string",
"tasks": {
"postTasks": [
{
"parameters": {},
"source": "string",
"taskScope": "string"
}
],
"preTasks": [
{
"parameters": {},
"source": "string",
"taskScope": "string"
}
]
},
"windowsParameters": {
"classificationsToInclude": [ "string" ],
"excludeKbsRequiringReboot": "bool",
"kbNumbersToExclude": [ "string" ],
"kbNumbersToInclude": [ "string" ]
}
},
"maintenanceScope": "string",
"maintenanceWindow": {
"duration": "string",
"expirationDateTime": "string",
"recurEvery": "string",
"startDateTime": "string",
"timeZone": "string"
},
"namespace": "string",
"visibility": "string"
}
}
Assign the configuration
Assign the configuration to a virtual machine.
For more information, see configurationAssignments.
{
"type": "Microsoft.Maintenance/configurationAssignments",
"apiVersion": "2021-09-01-preview",
"name": "[variables('maintenanceConfigurationAssignmentName')]",
"location": "string (e.g. westeurope)",
"scope": "Resource Id of the resource that is being assigned to the Maintenance Configuration (e.g. VMSS Id)"
"properties": {
"maintenanceConfigurationId": "Resource Id of the Maintenance Configuration"
"resourceId": "Resource Id of the resource that is being assigned to the Maintenance Configuration (e.g. VMSS Id)"
}
}