|
1 | 1 | --- |
2 | 2 | severity: Important |
3 | 3 | pillar: Operational Excellence |
4 | | -category: Monitoring |
| 4 | +category: OE:10 Automation design |
5 | 5 | resource: Virtual Machine |
6 | 6 | online version: https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.VM.Agent/ |
7 | 7 | ms-content-id: e4f6f6e7-593c-4507-811d-778ee8ec9ac4 |
8 | 8 | --- |
9 | 9 |
|
10 | | -# VM agent is provisioned automatically |
| 10 | +# Virtual Machine agent is not provisioned |
11 | 11 |
|
12 | 12 | ## SYNOPSIS |
13 | 13 |
|
14 | | -Ensure the VM agent is provisioned automatically. |
| 14 | +Virtual Machines (VMs) without an agent provisioned are unable to use monitoring, management, and security extensions. |
15 | 15 |
|
16 | 16 | ## DESCRIPTION |
17 | 17 |
|
18 | 18 | The virtual machine (VM) agent is required for most functionality that interacts with the guest operating system. |
| 19 | +This includes any VMs extensions such as Azure monitoring, management, and security features. |
19 | 20 |
|
20 | | -VM extensions help reduce management overhead by providing an entry point to bootstrap monitoring and configuration of the guest operating system. |
21 | | -The VM agent is required to use any VM extensions. |
| 21 | +Extensions help reduce management overhead by providing an entry point to bootstrap VM monitoring and configuration. |
| 22 | + |
| 23 | +By default, the VM agent is provisioned for all supported operating systems. |
22 | 24 |
|
23 | 25 | ## RECOMMENDATION |
24 | 26 |
|
25 | | -Automatically provision the VM agent for all supported operating systems, this is the default. |
| 27 | +Consider automatically provisioning the VM agent for all supported operating systems to reduce management overhead of VMs. |
| 28 | + |
| 29 | +## EXAMPLES |
| 30 | + |
| 31 | +### Configure with Azure template |
| 32 | + |
| 33 | +To deploy VMs that pass this rule: |
| 34 | + |
| 35 | +- Set the `properties.osProfile.linuxConfiguration.provisionVMAgent` property to `true` for Linux VMs. |
| 36 | +- Set the `properties.osProfile.windowsConfiguration.provisionVMAgent` property to `true` for Windows VMs. |
| 37 | + |
| 38 | +For example: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "type": "Microsoft.Compute/virtualMachines", |
| 43 | + "apiVersion": "2024-03-01", |
| 44 | + "name": "[parameters('name')]", |
| 45 | + "location": "[parameters('location')]", |
| 46 | + "identity": { |
| 47 | + "type": "SystemAssigned" |
| 48 | + }, |
| 49 | + "properties": { |
| 50 | + "hardwareProfile": { |
| 51 | + "vmSize": "Standard_D8d_v5" |
| 52 | + }, |
| 53 | + "osProfile": { |
| 54 | + "computerName": "[parameters('name')]", |
| 55 | + "adminUsername": "[parameters('adminUsername')]", |
| 56 | + "linuxConfiguration": { |
| 57 | + "provisionVMAgent": true, |
| 58 | + "disablePasswordAuthentication": true |
| 59 | + } |
| 60 | + }, |
| 61 | + "storageProfile": { |
| 62 | + "imageReference": { |
| 63 | + "publisher": "MicrosoftCblMariner", |
| 64 | + "offer": "Cbl-Mariner", |
| 65 | + "sku": "cbl-mariner-2-gen2", |
| 66 | + "version": "latest" |
| 67 | + }, |
| 68 | + "osDisk": { |
| 69 | + "name": "[format('{0}-disk0', parameters('name'))]", |
| 70 | + "caching": "ReadWrite", |
| 71 | + "createOption": "FromImage", |
| 72 | + "managedDisk": { |
| 73 | + "storageAccountType": "Premium_LRS" |
| 74 | + } |
| 75 | + } |
| 76 | + }, |
| 77 | + "networkProfile": { |
| 78 | + "networkInterfaces": [ |
| 79 | + { |
| 80 | + "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]" |
| 81 | + } |
| 82 | + ] |
| 83 | + } |
| 84 | + }, |
| 85 | + "zones": [ |
| 86 | + "1" |
| 87 | + ], |
| 88 | + "dependsOn": [ |
| 89 | + "[resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]" |
| 90 | + ] |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +### Configure with Bicep |
| 95 | + |
| 96 | +To deploy VMs that pass this rule: |
| 97 | + |
| 98 | +- Set the `properties.osProfile.linuxConfiguration.provisionVMAgent` property to `true` for Linux VMs. |
| 99 | +- Set the `properties.osProfile.windowsConfiguration.provisionVMAgent` property to `true` for Windows VMs. |
| 100 | + |
| 101 | +For example: |
| 102 | + |
| 103 | +```bicep |
| 104 | +resource linux 'Microsoft.Compute/virtualMachines@2024-03-01' = { |
| 105 | + name: name |
| 106 | + location: location |
| 107 | + identity: { |
| 108 | + type: 'SystemAssigned' |
| 109 | + } |
| 110 | + properties: { |
| 111 | + hardwareProfile: { |
| 112 | + vmSize: 'Standard_D8d_v5' |
| 113 | + } |
| 114 | + osProfile: { |
| 115 | + computerName: name |
| 116 | + adminUsername: adminUsername |
| 117 | + linuxConfiguration: { |
| 118 | + provisionVMAgent: true |
| 119 | + disablePasswordAuthentication: true |
| 120 | + } |
| 121 | + } |
| 122 | + storageProfile: { |
| 123 | + imageReference: { |
| 124 | + publisher: 'MicrosoftCblMariner' |
| 125 | + offer: 'Cbl-Mariner' |
| 126 | + sku: 'cbl-mariner-2-gen2' |
| 127 | + version: 'latest' |
| 128 | + } |
| 129 | + osDisk: { |
| 130 | + name: '${name}-disk0' |
| 131 | + caching: 'ReadWrite' |
| 132 | + createOption: 'FromImage' |
| 133 | + managedDisk: { |
| 134 | + storageAccountType: 'Premium_LRS' |
| 135 | + } |
| 136 | + } |
| 137 | + } |
| 138 | + networkProfile: { |
| 139 | + networkInterfaces: [ |
| 140 | + { |
| 141 | + id: nic.id |
| 142 | + } |
| 143 | + ] |
| 144 | + } |
| 145 | + } |
| 146 | + zones: [ |
| 147 | + '1' |
| 148 | + ] |
| 149 | +} |
| 150 | +``` |
| 151 | + |
| 152 | +## NOTES |
| 153 | + |
| 154 | +In general provisioning the VM agent is recommended for all supported operating systems. |
| 155 | +For network virtual appliances (NVAs) or specialized unsupported OS images installed from the Azure Marketplace, |
| 156 | +the VM agent may be disabled by the publisher. |
26 | 157 |
|
27 | 158 | ## LINKS |
28 | 159 |
|
| 160 | +- [OE:10 Automation design](https://learn.microsoft.com/azure/well-architected/operational-excellence/enable-automation) |
29 | 161 | - [Azure deployment reference](https://learn.microsoft.com/azure/templates/microsoft.compute/virtualmachines) |
0 commit comments