Ensure that Azure Virtual Machine is assigned to an availability set
Risk Level: High
Cloud Entity: Virtual Machine
CloudGuard Rule ID: D9.AZU.DR.03
Covered by Spectral: Yes
Category: Compute
GSL LOGIC
VirtualMachine where isScaleSetVm=false should have availabilitySetREMEDIATION
From Portal
- Go to 'Resource Groups' and filter the availability set
- Select the Availability set and click on 'Overview'
- Now click on 'Create' button and 'Virtual Machine'
- Now provide all the necessary details and hit Review + Create
- Click Save.
From TF
Set the 'availability_set_id' argument under azurerm_windows_virtual_machine
resource "azurerm_windows_virtual_machine" "example" {
..
availability_set_id = AVAILABILITYSETID
..
}Note: You can put azurerm_windows_virtual_machine or azurerm_linux_virtual_machine, whichever VM you want to assign to an availability set
From Command Line
First create Availability Set and Resource Group using below Command:-
Run
az group create --name RESOURCEGROUPNAME --location LOCATION
az vm availability-set create --resource-group RESOURCEGROUPNAME --name AVAILABILITYSETNAME --platform-fault-domain-count COUNT --platform-update-domain-count COUNTNow, create the VM using the --availability-set parameter to specify the name of the availability set
Run
for i in `seq 1 2`; do
az vm create --resource-group RESOURCEGROUPNAME --name VMNAME --availability-set AVAILABILITYSETNAME --size VMSIZE --vnet-name VNETNAME --subnet SUBNETNAME --image IMAGE --admin-username USERNAME --generate-ssh-keys
done
Note: An existing VM cannot be added to an availability set after it is created.
References
- https://docs.microsoft.com/en-us/azure/virtual-machines/availability-set-overview
- https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-availability-sets
- https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_virtual_machine#availability_set_id
Virtual Machine
Azure Virtual Machines (VM) is one of several types of on-demand, scalable computing resources that Azure offers. Typically, you choose a VM when you need more control over the computing environment than the other choices offer. This article gives you information about what you should consider before you create a VM, how you create it, and how you manage it.
Compliance Frameworks
- Azure CloudGuard Best Practices
- Azure HITRUST v9.5.0
- Azure NIST 800-53 Rev 5
- CloudGuard Azure All Rules Ruleset
Updated 7 months ago