Creating Availability Sets for Virtual Machines in Azure with PowerShell
Josh Duffney
Posted on December 4, 2019
Create a Resource Group
$splat = @{
Name = 'availabilitySet-rg'
Location = 'CentralUS'
}
New-AzResourceGroup @splat
Create a Managed Availability Set
$splat = @{
Location = "CentralUS"
Name = "availabilitySetPractice"
ResourceGroupName = "availabilitySet-rg"
Sku = "aligned"
PlatformFaultDomainCount = 2
PlatformUpdateDomainCount = 2
}
New-AzAvailabilitySet @splat
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 `
}
Delete Resources Clean-up
Remove-AzResourceGroup -Name 'availabilitySet-rg'
Sources
Tutorial: Create and deploy highly available virtual machines with Azure PowerShell
Manage the availability of Windows virtual machines in Azure
π πͺ π
π©
Josh Duffney
Posted on December 4, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
azure Securing Your Azure Cloud Environment with Application Security Groups (ASGs)
November 28, 2024