Skip to main content
Jorge Bernhardt Jorge Bernhardt
  1. Posts/

How to create an Azure Availability Set

·528 words·3 mins· 100 views · 5 likes ·
Azure CLI Azure Cloud Shell Azure PowerShell Connect-AzAccount

An Azure availability set is a group with two or more virtual machines in the same data center, their implementation ensures that at least one of the virtual machines hosted in the availability set will be available during a host update event or a failure in the host’s physical hardware. In this post,  I want to show you how to create Azure availability sets using PowerShell and Azure CLI.

Prerequisites>

Prerequisites #

  • This tutorial assumes that you already have a Microsoft Azure account configured.
  • You created a Resource Group for these resources and the new ones deployed in this tutorial will join that group. If you want to know how to create a Resource Group, check out this  link.

Important: You can configure an Availability Set only when you deploy a new Virtual Machine, you can’t add an existing Virtual Machine to an Availability Set.

Azure PowerShell Workaround>

Azure PowerShell Workaround #

If you want to know how to install the PowerShell Azure module on your machine, check out this link. The simplest way to get started is to sign in interactively at the command line.

Connect-AzAccount

This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account. If you have more than one subscription associated with your mail account, you can choose the default subscription. To perform this task, we will use the following commands:

Get-AzSubscription
Select-AzSubscription -Subscription "My Subscription"

Once you set your default subscription, you’re ready to start.

Set the variables>

Set the variables #

Here, we define the characteristics of our environment and the resource’s properties.

$resourceGroupName = "RG-DEMO-NE"
$avSetName = "AV-DEMO-WEBPS"
$location = "North Europe"

To create an availability set, use the New-AzAvailabilitySet cmdlet.

New-AzAvailabilitySet `
    -Name $avSetName `
    -ResourceGroupName $resourceGroupName `
    -Location $location `
    -PlatformFaultDomainCount 2 `
    -PlatformUpdateDomainCount 5 `
    -Sku "Aligned"

New-AzAvailabilitySet
Parameters

  • -PlatformFaultDomainCount: Specifies the platform fault domain count. In this example, the first two virtual machines implemented in the availability set are located in two different fault domains, which guarantees that a single point of failure will not affect both simultaneously.
  • -PlatformUpdateDomainCount: Specifies the platform update domain count. In this example*,* the first five VMS implemented in the availability set are located in five different update domains, which minimizes the impact when the Azure platform updates the host operating system, as one domain is updated at a time.
  • -Sku: This parameter must be set to “Aligned” if you intend to deploy virtual machines that use managed disks otherwise use the value “Classic”
Azure CLI Workaround>

Azure CLI Workaround #

In this case, we will use Azure Cloud Shell, a browser-based shell built into Azure Portal. This allows us to use the Azure command-line tools (Azure CLI and Azure PowerShell) directly from a browser. If you want to know more about Azure Cloud Shell, check out this link

resourceGroupName="RG-DEMO-NE"
avSetName="AV-DEMO-WEBCLI"
location="NorthEurope"

az vm availability-set create \
-n $avSetName \
-g $resourceGroupName \
-l $location \
--platform-fault-domain-count 2 \
--platform-update-domain-count 5

Azure availability sets

Thanks for reading my post. I hope you find it useful.

You can learn more about update and fault domains and how to manage the availability of your Azure VMs here.