Azure Compute Availability Set
This page shows how to write Terraform and Azure Resource Manager for Compute Availability Set and write them securely.
azurerm_availability_set (Terraform)
The Availability Set in Compute can be configured in Terraform with the resource name azurerm_availability_set
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_availability_set" "AVSET1" {
name = "AvailabilitySet1"
location = local.location
resource_group_name = local.ResourceGroup
tags = {
resource "azurerm_availability_set" "as_web" {
name = var.web_tier.as.name
location = azurerm_resource_group.rg_appweb.location
resource_group_name = azurerm_resource_group.rg_appweb.name
tags = merge(local.global_settings.tags_hub, var.web_tier.as.tags)
platform_fault_domain_count = 2
resource "azurerm_availability_set" "AVSET1" {
name = "AvailabilitySet1"
location = local.location
resource_group_name = local.ResourceGroup
platform_update_domain_count = local.updateDomain
resource "azurerm_availability_set" "avsetweb" {
name = var.avset_name_web
location = var.location
resource_group_name = azurerm_resource_group.rg.name
platform_fault_domain_count = 2
platform_update_domain_count = 2
resource "azurerm_availability_set" "lab" {
name = "aset-hml"
location = azurerm_resource_group.lab.location
resource_group_name = azurerm_resource_group.lab.name
}
resource "azurerm_availability_set" "web-av-set" {
name = var.web-av-set-name
location = var.rg-location
resource_group_name = var.rg-name
}
resource "azurerm_availability_set" "web_availabilty_set" {
name = "web_availabilty_set"
location = var.location
resource_group_name = var.resource_group
}
resource "azurerm_availability_set" "as_web" {
name = var.web_tier.as.name
location = azurerm_resource_group.rg_appweb.location
resource_group_name = azurerm_resource_group.rg_appweb.name
tags = merge(local.global_settings.tags_hub, var.web_tier.as.tags)
platform_fault_domain_count = 2
resource "azurerm_availability_set" "web_availabilty_set" {
name = "web_availabilty_set"
location = var.location
resource_group_name = var.resource_group
}
resource "azurerm_availability_set" "Controller-AS" {
name = "Controller-AS"
location = var.AzureRegion
managed = "true"
resource_group_name = var.RGName
tags = {
Parameters
-
id
optional computed - string -
location
required - string -
managed
optional - bool -
name
required - string -
platform_fault_domain_count
optional - number -
platform_update_domain_count
optional - number -
proximity_placement_group_id
optional - string -
resource_group_name
required - string -
tags
optional - map from string to string -
timeouts
single block
Explanation in Terraform Registry
Manages an Availability Set for Virtual Machines.
Tips: Best Practices for The Other Azure Compute Resources
In addition to the azurerm_linux_virtual_machine, Azure Compute has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_linux_virtual_machine
Ensure to use SSH authentication for virtual machines
It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.
azurerm_managed_disk
Ensure to enable the encryption on managed disks
It is better to enable the encryption on managed disks.
azurerm_virtual_machine
Ensure to use SSH authentication for virtual machines
It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.
Microsoft.Compute/availabilitySets (Azure Resource Manager)
The availabilitySets in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/availabilitySets
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Compute/availabilitySets",
"name": "[parameters('adAvailabilitySetName')]",
"apiVersion": "2015-06-15",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Compute/availabilitySets",
"name": "[parameters('adAvailabilitySetName')]",
"apiVersion": "2015-06-15",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Compute/availabilitySets",
"name": "[parameters('adAvailabilitySetName')]",
"apiVersion": "2015-06-15",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Compute/availabilitySets",
"name": "[parameters('adAvailabilitySetName')]",
"apiVersion": "2015-06-15",
"location": "[parameters('location')]",
"properties": {
}
"type": "Microsoft.Compute/availabilitySets",
"name": "[parameters('adAvailabilitySetName')]",
"apiVersion": "2015-06-15",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Compute/availabilitySets",
"name": "{{availabilitySetMasters}}",
"apiVersion": "{{apiVersion}}",
"location": "[resourceGroup().location]",
"properties": {
"PlatformFaultDomainCount": "{{faultDomainCount}}",
"type": "Microsoft.Compute/availabilitySets",
"name": "[parameters('adAvailabilitySetName')]",
"apiVersion": "2015-06-15",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.Compute/availabilitySets",
"name": "{{availabilitySetMasters}}",
"apiVersion": "{{apiVersion}}",
"location": "[resourceGroup().location]",
"properties": {
"PlatformFaultDomainCount": "{{faultDomainCount}}",
"type": "Microsoft.Compute/availabilitySets",
"name": "[parameters('adAvailabilitySetName')]",
"apiVersion": "2017-12-01",
"location": "[parameters('location')]",
"sku": {
"name": "Aligned"
"type": "Microsoft.Compute/availabilitySets",
"name": "[parameters('adAvailabilitySetName')]",
"apiVersion": "2017-12-01",
"location": "[parameters('location')]",
"sku": {
"name": "Aligned"
Parameters
apiVersion
required - stringlocation
required - stringResource location
name
required - stringThe name of the availability set.
properties
requiredplatformFaultDomainCount
optional - integerFault Domain count.
platformUpdateDomainCount
optional - integerUpdate Domain count.
proximityPlacementGroup
optionalid
optional - stringResource Id
virtualMachines
optional arrayid
optional - stringResource Id
sku
optionalcapacity
optional - integerSpecifies the number of virtual machines in the scale set.
name
optional - stringThe sku name.
tier
optional - stringSpecifies the tier of virtual machines in a scale set. Possible Values: Standard Basic
tags
optional - stringResource tags
type
required - string
Frequently asked questions
What is Azure Compute Availability Set?
Azure Compute Availability Set is a resource for Compute of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Compute Availability Set?
For Terraform, the rabindra-dahal/Terraform-resource-group-learning, sk1020/Landing-Zone and gitbhushan/terraform999 source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the mikenelson-io/Azure-DevTest-Labs, sourton2013/Azure and linuxacademy/content-azure-70532 source code examples are useful. See the Azure Resource Manager Example section for further details.