|
| 1 | +--- |
| 2 | +severity: Important |
| 3 | +pillar: Reliability |
| 4 | +category: RE:07 Self-preservation |
| 5 | +resource: Virtual Machine Scale Sets |
| 6 | +online version: https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.VMSS.AutoInstanceRepairs/ |
| 7 | +--- |
| 8 | + |
| 9 | +# Automatic instance repairs |
| 10 | + |
| 11 | +## SYNOPSIS |
| 12 | + |
| 13 | +Automatic instance repairs are enabled. |
| 14 | + |
| 15 | +## DESCRIPTION |
| 16 | + |
| 17 | +Enabling automatic instance repairs helps to achieve high application availability by automatically detecting and recovering unhealthy VM instances at runtime. |
| 18 | + |
| 19 | +The automatic instance repair feature relies on health monitoring of individual VM instances in a scale set. |
| 20 | +VM Instances in a scale set can be configured to emit application health status using either the Application Health extension or Load balancer health probes. |
| 21 | +If an VM instance is found to be unhealthy, the scale set will perform a preconfigured repair action on the unhealthy VM instance. |
| 22 | +Automatic instance repairs can be enabled in the Virtual Machine Scale Set model by using the `automaticRepairsPolicy` object. |
| 23 | + |
| 24 | +See documentation references below for additional limitations and important information. |
| 25 | + |
| 26 | +## RECOMMENDATION |
| 27 | + |
| 28 | +Consider enabling automatic instance repairs to achieve high application availability by maintaining a set of healthy VM instances. |
| 29 | + |
| 30 | +## EXAMPLES |
| 31 | + |
| 32 | +### Configure with Azure template |
| 33 | + |
| 34 | +To deploy virtual machine scale sets that pass this rule: |
| 35 | + |
| 36 | +- Set the `properties.automaticRepairsPolicy.enabled` property to `true`. |
| 37 | + |
| 38 | +For example: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "type": "Microsoft.Compute/virtualMachineScaleSets", |
| 43 | + "apiVersion": "2023-09-01", |
| 44 | + "name": "[parameters('name')]", |
| 45 | + "location": "[parameters('location')]", |
| 46 | + "sku": { |
| 47 | + "name": "b2ms", |
| 48 | + "tier": "Standard", |
| 49 | + "capacity": 1 |
| 50 | + }, |
| 51 | + "properties": { |
| 52 | + "automaticRepairsPolicy": { |
| 53 | + "enabled": true |
| 54 | + } |
| 55 | + } |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +### Configure with Bicep |
| 60 | + |
| 61 | +To deploy virtual machine scale sets that pass this rule: |
| 62 | + |
| 63 | +- Set the `properties.automaticRepairsPolicy.enabled` property to `true`. |
| 64 | + |
| 65 | +For example: |
| 66 | + |
| 67 | +```bicep |
| 68 | +resource vmss 'Microsoft.Compute/virtualMachineScaleSets@2023-09-01' = { |
| 69 | + name: name |
| 70 | + location: location |
| 71 | + sku: { |
| 72 | + name: 'b2ms' |
| 73 | + tier: 'Standard' |
| 74 | + capacity: 1 |
| 75 | + } |
| 76 | + properties: { |
| 77 | + automaticRepairsPolicy: { |
| 78 | + enabled: true |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +## NOTES |
| 85 | + |
| 86 | +This feature for virtual machine scale sets is currently in preview. |
| 87 | + |
| 88 | +In order for automatic repairs policy to work properly, ensure that all the requirements for opting in to this feature are met. |
| 89 | + |
| 90 | +## LINKS |
| 91 | + |
| 92 | +- [RE:07 Self-preservation](https://learn.microsoft.com/azure/well-architected/reliability/self-preservation) |
| 93 | +- [Automatic instance repairs](https://learn.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-automatic-instance-repairs) |
| 94 | +- [Azure resource deployment](https://learn.microsoft.com/azure/templates/microsoft.compute/virtualmachinescalesets#automaticrepairspolicy) |
0 commit comments