DEV Community

Josh Duffney
Josh Duffney

Posted on

1

Creating Availability Sets for Virtual Machines in Azure with PowerShell

Create a Resource Group

$splat = @{
    Name = 'availabilitySet-rg'
    Location = 'CentralUS'
}

New-AzResourceGroup @splat
Enter fullscreen mode Exit fullscreen mode

Create a Managed Availability Set

$splat = @{
    Location = "CentralUS"
    Name = "availabilitySetPractice"
    ResourceGroupName = "availabilitySet-rg"
    Sku = "aligned"
    PlatformFaultDomainCount = 2
    PlatformUpdateDomainCount = 2
}

New-AzAvailabilitySet @splat
Enter fullscreen mode Exit fullscreen mode

Important notes:

  • SKU aligned means it uses managed disk.
  • Fault Domain max is 3 (currently & depends on region)
  • Update Domain max is 20 (currently)
  • Availability sets are under a 99.95% Azure SLA.

Create Virtual Machines in an Availability Set

$cred = Get-Credential

1..2 | ForEach-Object -Parallel {
    New-AzVm `
        -ResourceGroupName "availabilitySet-rg" `
        -Name "myVM$_" `
        -Location "CentralUS" `
        -VirtualNetworkName "vNet" `
        -SubnetName "Subnet" `
        -SecurityGroupName "NSG" `
        -PublicIpAddressName "publicIpAddress$_" `
        -AvailabilitySetName "availabilitySetPractice" `
        -Credential $using:cred `
}
Enter fullscreen mode Exit fullscreen mode

Delete Resources Clean-up

Remove-AzResourceGroup -Name 'availabilitySet-rg'
Enter fullscreen mode Exit fullscreen mode

Sources

Tutorial: Create and deploy highly available virtual machines with Azure PowerShell

Manage the availability of Windows virtual machines in Azure

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay