Windows Clustering In Azure: The Load Balancer

Deploying Windows failover clusters is a common way to improve availability for many workloads – including SQL Server, file services, and other services. Setting up and maintaining a failover cluster has become increasing simple in Windows with improvements to Windows Server over the last twenty or so years – including Cluster Aware Updating, Cluster Shared Volumes (CSVs), and Storage Spaces Direct (S2D)… as well as all sorts of other great innovations.

Creating Windows Clusters in Azure is a necessity for many workloads that may not be easy to move to a native Azure PAAS service. Azure Files Shares (for example) provides a great, serverless file sharing infrastructure… but doesn’t fit all migration scenarios and can be better for some use cases if you deploy a VM as a high speed cache (lots of reasons to do this – should be another blog post!). To make that Azure-based, VM cache highly available, arguably the best way is to create a Windows failover cluster!

I’ll walk through some of these “special” steps and considerations below (walking through creating an Azure File Sync cluster) – hopefully it makes sense!

I’m going to show you how to step through the magic using PowerShell… since it has allowed me to reduce the frequency of my “messups” using the portal.

The Setup – Some Variables You’ll need

With PowerShell, I’m a big fan of cut and pasting into my session… and with that I usually set the variables (constants) I’ll be using. To setup a cluster, I typically use the following somewhat self explanatory variables:

######## Configurable Variables ########
$Subscription = "11111111-1111-1111-1111-111111111111"
$ResourceGroupName = 'Infrastructure'
$location = 'USGov Virginia'
$ImageName = 'Win2019Datacenter'
$VnetName = 'VNet-Infra'
$SubNet = 'default'
$VMSize = 'Standard_DS3_v2'
$DataDiskSize = 512
$storageType = 'Premium_LRS'
$NodePrefix = 'CL'
$NodeCount = 2

I’ll also just mention that I do a lot of my work in Azure Government, so you may notice my Azure “locations” may look a little off what you might be used to using.

Once all the variables are set, you’ll want to log in, and select the appropriate subscription.
Again, I’m going to connect to Azure Government
– I’m specifying that as part of -EnvironmentName


#Connect to Azure
Connect-AzAccount -EnvironmentName AzureUSGovernment 	

#Select the target subscription for the current session
Select-AzSubscription -SubscriptionId $Subscription

Clusters in Azure Need a Cluster IP Address!

The big challenge creating a Windows failover cluster in Azure is the cluster IP address. Azure doesn’t just hand out IP addresses on your subnets via DHCP to anything that asks… so getting an IP address for your cluster to share is a little more complicated in Azure.

It’s not a big deal to reserve an IP address for your cluster – you simply need to provision up a Load Balancer in Azure (and add your cluster nodes to an Availability Set wired to it) – you will use the IP of the Load Balancer as the cluster IP!

Creating the Availability Set and Load Balancer is pretty simple code:

# Create availability set for Load Balancer - Load Balancer required to reserve shared IP address, and LB needs the availability set

New-AzAvailabilitySet -Location $location -Name $NodePrefix -ResourceGroupName $ResourceGroupName -Sku aligned -PlatformFaultDomainCount 2 -PlatformUpdateDomainCount 2


# build Load Balancer for File Server Cluster using https://docs.microsoft.com/en-us/azure/load-balancer/load-balancer-get-started-ilb-arm-ps 

$LBName = $NodePrefix + '_LB'
$LBBackName = $LBName + 'BE'
$vnet = Get-AzVirtualNetwork -Name $VnetName -ResourceGroupName $ResourceGroupName
$frontendIP = New-AzLoadBalancerFrontendIpConfig -Name LB-Frontend -PrivateIpAddress $FilesIP -SubnetId $vnet.subnets[0].Id
$beaddresspool= New-AzLoadBalancerBackendAddressPoolConfig -Name "LB-backend"
$backendSubnet = Get-AzVirtualNetworkSubnetConfig -Name $SubNet -VirtualNetwork $vnet
$healthProbe = New-AzLoadBalancerProbeConfig -Name "HealthProbe" -RequestPath "HealthProbe.aspx" -Protocol http -Port 59999 -IntervalInSeconds 5 -ProbeCount 2
$lbrule = New-AzLoadBalancerRuleConfig -Name "Port445" -FrontendIpConfiguration $frontendIP -BackendAddressPool $beAddressPool -Probe $healthProbe -Protocol Tcp -FrontendPort 80 -BackendPort 445
$NRPLB = New-AzLoadBalancer -ResourceGroupName $ResourceGroupName -Name $LBName -Location $location -FrontendIpConfiguration $frontendIP -LoadBalancingRule $lbrule -BackendAddressPool $beAddressPool -Probe $healthProbe

So that’s the setup for the cluster that’s Azure specific.

As time permits, I’ll add more posts showing how to create the nodes with either Storage Spaces Direct (separate, replicating disk storage) or using a shared disk in Azure.