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

AVSET.tf#L28
resource "azurerm_availability_set" "AVSET1" {
  name                = "AvailabilitySet1"
  location            = local.location
  resource_group_name = local.ResourceGroup

  tags = {
app_tiers.tf#L40
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
AVSET-using-locals-reference.tf#L22
resource "azurerm_availability_set" "AVSET1" {
  name                = "AvailabilitySet1"
  location            = local.location
  resource_group_name = local.ResourceGroup

  platform_update_domain_count = local.updateDomain
avset.tf#L2
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
avalabilitiyset.tf#L2
resource "azurerm_availability_set" "lab" {
  name                = "aset-hml"
  location            = azurerm_resource_group.lab.location
  resource_group_name = azurerm_resource_group.lab.name

}
compute.tf#L1
resource "azurerm_availability_set" "web-av-set" {
  name                          = var.web-av-set-name
  location                      = var.rg-location
  resource_group_name           = var.rg-name

}
main.tf#L1
resource "azurerm_availability_set" "web_availabilty_set" {
  name                = "web_availabilty_set"
  location            = var.location
  resource_group_name = var.resource_group
}

app_tiers.tf#L40
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
compute.tf#L1
resource "azurerm_availability_set" "web_availabilty_set" {
  name                = "web_availabilty_set"
  location            = var.location
  resource_group_name = var.resource_group
}

05-AvailibiltySets.tf#L3
resource "azurerm_availability_set" "Controller-AS" {
  name                = "Controller-AS"
  location            = var.AzureRegion
  managed             = "true"
  resource_group_name = var.RGName
  tags = {

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

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.

risk-label

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.

risk-label

azurerm_managed_disk

Ensure to enable the encryption on managed disks

It is better to enable the encryption on managed disks.

risk-label

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.

Review your Azure Compute settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

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

availabilitySets.json#L20
      "type": "Microsoft.Compute/availabilitySets",
      "name": "[parameters('adAvailabilitySetName')]",
      "apiVersion": "2015-06-15",
      "location": "[parameters('location')]"
    },
    {
availabilitySets.json#L20
      "type": "Microsoft.Compute/availabilitySets",
      "name": "[parameters('adAvailabilitySetName')]",
      "apiVersion": "2015-06-15",
      "location": "[parameters('location')]"
    },
    {
availabilitySets.json#L20
      "type": "Microsoft.Compute/availabilitySets",
      "name": "[parameters('adAvailabilitySetName')]",
      "apiVersion": "2015-06-15",
      "location": "[parameters('location')]"
    },
    {
availabilitySets.json#L23
      "type": "Microsoft.Compute/availabilitySets",
      "name": "[parameters('adAvailabilitySetName')]",
      "apiVersion": "2015-06-15",
      "location": "[parameters('location')]",
      "properties": {
      }
availabilitySets.json#L20
      "type": "Microsoft.Compute/availabilitySets",
      "name": "[parameters('adAvailabilitySetName')]",
      "apiVersion": "2015-06-15",
      "location": "[parameters('location')]"
    },
    {
availability-sets.json#L10
      "type": "Microsoft.Compute/availabilitySets",
      "name": "{{availabilitySetMasters}}",
      "apiVersion": "{{apiVersion}}",
      "location": "[resourceGroup().location]",
      "properties": {
        "PlatformFaultDomainCount": "{{faultDomainCount}}",
availabilitySets.json#L20
      "type": "Microsoft.Compute/availabilitySets",
      "name": "[parameters('adAvailabilitySetName')]",
      "apiVersion": "2015-06-15",
      "location": "[parameters('location')]"
    },
    {
availability-sets.json#L10
      "type": "Microsoft.Compute/availabilitySets",
      "name": "{{availabilitySetMasters}}",
      "apiVersion": "{{apiVersion}}",
      "location": "[resourceGroup().location]",
      "properties": {
        "PlatformFaultDomainCount": "{{faultDomainCount}}",
availabilitySets.json#L20
      "type": "Microsoft.Compute/availabilitySets",
      "name": "[parameters('adAvailabilitySetName')]",
      "apiVersion": "2017-12-01",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Aligned"
availabilitySets.json#L20
      "type": "Microsoft.Compute/availabilitySets",
      "name": "[parameters('adAvailabilitySetName')]",
      "apiVersion": "2017-12-01",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Aligned"

Parameters

  • apiVersion required - string
  • location required - string

    Resource location

  • name required - string

    The name of the availability set.

  • properties required
      • platformFaultDomainCount optional - integer

        Fault Domain count.

      • platformUpdateDomainCount optional - integer

        Update Domain count.

      • proximityPlacementGroup optional
          • id optional - string

            Resource Id

      • virtualMachines optional array
          • id optional - string

            Resource Id

  • sku optional
      • capacity optional - integer

        Specifies the number of virtual machines in the scale set.

      • name optional - string

        The sku name.

      • tier optional - string

        Specifies the tier of virtual machines in a scale set. Possible Values: Standard Basic

  • tags optional - string

    Resource 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.