Setting Value
Name A text name representing the load balancer. For example, sqlLB.
Internal: Most implementations use an internal load balancer, which
allows applications within the same virtual network to connect to the
Type availability group.
External: Allows applications to connect to the availability group through
a public Internet connection.
Virtual network Select the virtual network that the SQL Server instances are in.
Subnet Select the subnet that the SQL Server instances are in.
IP address
Static
assignment
Specify an available IP address from the subnet. Use this IP address when
Private IP
you create a listener on the cluster. In a PowerShell script, later in this
address
article, use this address for the $ILBIP variable.
If you have multiple subscriptions, this field might appear. Select the
Subscription subscription that you want to associate with this resource. It is normally
the same subscription as all the resources for the availability group.
Resource group Select the resource group that the SQL Server instances are in.
Location Select the Azure location that the SQL Server instances are in.
6. Click Create.
Azure creates the load balancer. The load balancer belongs to a specific network, subnet, resource
group, and location. After Azure completes the task, verify the load balancer settings in Azure.
Setting Value
A text name representing the probe. For example,
Name
SQLAlwaysOnEndPointProbe.
Protocol TCP
Port You can use any available port. For example, 59999.
Interval 5
Unhealthy
2
threshold
4. Click OK.
Note
Make sure that the port you specify is open on the firewall of both SQL Server instances. Both
instances require an inbound rule for the TCP port that you use. For more information, see Add or
Edit Firewall Rule.
Azure creates the probe and then uses it to test which SQL Server instance has the listener for the
availability group.
Setting Value
A text name representing the load balancing rules. For example,
Name
SQLAlwaysOnEndPointListener.
Protocol TCP
Port 1433
Setting Value
1433. This value is ignored because this rule uses Floating IP
Backend Port
(direct server return).
Probe Use the name of the probe that you created for this load balancer.
Session persistence None
Idle timeout (minutes) 4
Floating IP (direct
Enabled
server return)
Note
You might have to scroll down the blade to view all the settings.
4. Click OK.
5. Azure configures the load balancing rule. Now the load balancer is configured to route
traffic to the SQL Server instance that hosts the listener for the availability group.
At this point, the resource group has a load balancer that connects to both SQL Server machines.
The load balancer also contains an IP address for the SQL Server Always On availability group
listener, so that either machine can respond to requests for the availability groups.
Note
If your SQL Server instances are in two separate regions, repeat the steps in the other region. Each
region requires a load balancer.
c. In the Name box, create a name for this new listener. The name for the new listener is the
network name that applications use to connect to databases in the SQL Server availability
group.
d. To finish creating the listener, click Next twice, and then click Finish. Do not bring the
listener or resource online at this point.
3. Take the availability group cluster role offline. In Failover Cluster Manager under Roles,
right-click the role, and select Stop Role.
4. Configure the IP resource for the availability group.
a. Click the Resources tab, and then expand the client access point you created.
The client access point is offline.
b. Right-click the IP resource, and then click properties. Note the name of the IP address,
and use it in the $IPResourceName variable in the PowerShell script.
c. Under IP Address, click Static IP Address. Set the IP address as the same address that
you used when you set the load balancer address on the Azure portal.
5. Make the SQL Server availability group resource dependent on the client access point.
a. In Failover Cluster Manager, click Roles, and then click your availability group.
b. On the Resources tab, under Other Resources, right-click the availability resource
group, and then click Properties.
c. On the dependencies tab, add the name of the client access point (the listener) resource.
d. Click OK.
6. Make the client access point resource dependent on the IP address.
a. In Failover Cluster Manager, click Roles, and then click your availability group.
b. On the Resources tab, right-click the client access point resource under Server Name,
and then click Properties.
c. Click the Dependencies tab. Verify that the IP address is a dependency. If it is not, set a
dependency on the IP address. If there are multiple resources listed, verify that the IP
addresses have OR, not AND, dependencies. Click OK.
Tip
You can validate that the dependencies are correctly configured. In Failover Cluster
Manager, go to Roles, right-click the availability group, click More Actions, and then click
Show Dependency Report. When the dependencies are correctly configured, the
availability group is dependent on the network name, and the network name is dependent on
the IP address.
7. Set the cluster parameters in PowerShell.
a. Copy the following PowerShell script to one of your SQL Server instances. Update the
variables for your environment.
• $ListenerILBIP is the IP address that you created on the Azure load balancer for
the availability group listener.
• $ListenerProbePort is the port you configured on the Azure load balancer for
the availability group listener.
PowerShell
7. $ClusterNetworkName = "<MyClusterNetworkName>" # the cluster network name
(Use Get-ClusterNetwork on Windows Server 2012 of higher to find the name)
$IPResourceName = "<IPResourceName>" # the IP Address resource name
$ListenerILBIP = "<n.n.n.n>" # the IP Address of the Internal Load
Balancer (ILB). This is the static IP address for the load balancer you
configured in the Azure portal.
[int]$ListenerProbePort = <nnnnn>
Import-Module FailoverClusters
b. Set the cluster parameters by running the PowerShell script on one of the cluster nodes.
Note
If your SQL Server instances are in separate regions, you need to run the PowerShell script
twice. The first time, use the $ListenerILBIP and $ListenerProbePort from the
first region. The second time, use the $ListenerILBIP and $ListenerProbePort
from the second region. The cluster network name and the cluster IP resource name are also
different for each region.
8. Bring the availability group cluster role online. In Failover Cluster Manager under Roles,
right click the role, and select Start Role.
If necessary, repeat the steps above to set the cluster parameters for the WSFC cluster IP address.
1. Get the IP address name of the WSFC Cluster IP address. In Failover Cluster Manager
under Cluster Core Resources, locate Server Name.
2. Right-click IP Address, and select Properties.
3. Copy the Name of the IP address. It may be Cluster IP Address.
b. Set the cluster parameters by running the PowerShell script on one of the cluster nodes.
Warning
The availability group listener health probe port has to be different from the cluster core IP address
health probe port. In these examples, the listener port is 59999 and the cluster core IP address is
58888. Both ports require an allow inbound firewall rule.
2. sqlcmd -S <listenerName> -E
The SQLCMD connection automatically connects to the SQL Server instance that hosts the primary
replica.
Setting Value
Name A name to identify the probe.
Protocol TCP
An unused TCP port, which must be available on all virtual machines. It
Port cannot be used for any other purpose. No two listeners can use the same
probe port.
Interval The amount of time between probe attempts. Use the default (5).
Unhealthy The number of consecutive thresholds that should fail before a virtual
threshold machine is considered unhealthy.
8. Click OK to save the probe.
9. Create a load balancing rule. Click Load balancing rules, and then click Add.
10.Configure the new load balancing rule by using the following settings:
Setting Value
Name A name to identify the load balancing rule.
Frontend IP address Select the IP address you created.
Protocol TCP
Use the port that the SQL Server instances are using. A default
Port
instance uses port 1433, unless you changed it.
Backend port Use the same value as Port.
The pool that contains the virtual machines with the SQL Server
Backend pool
instances.
Health probe Choose the probe you created.
Session persistence None
Idle timeout (minutes) Default (4)
Floating IP (direct
Enabled
server return)
Configure the availability group to use the new IP address
To finish configuring the cluster, repeat the steps that you followed when you made the first
availability group. That is, configure the cluster to use the new IP address.
After you have added an IP address for the listener, configure the additional availability group by
doing the following:
1. Verify that the probe port for the new IP address is open on both SQL Server virtual
machines.
2. In Cluster Manager, add the client access point.
3. Configure the IP resource for the availability group.
Important
When you create the IP address, use the IP address that you added to the load balancer.
4. Make the SQL Server availability group resource dependent on the client access point.
5. Make the client access point resource dependent on the IP address.
6. Set the cluster parameters in PowerShell.
After you configure the availability group to use the new IP address, configure the connection to the
listener.
Setting Value
A name to identify the load balancing rule for the distributed
Name
availability group.
Frontend IP address Use the same frontend IP address as the availability group.
Protocol TCP
5022 - The port for the distributed availability group endpoint
Port listener.
Can be any available port.
Backend port 5022 - Use the same value as Port.
Setting Value
The pool that contains the virtual machines with the SQL
Backend pool
Server instances.
Health probe Choose the probe you created.
Session persistence None
Idle timeout (minutes) Default (4)
Floating IP (direct server
Enabled
return)
Repeat these steps for the load balancer on the other availability groups that participate in the
distributed availability groups.
If you are restricting access with an Azure Network Security Group, ensure that the allow rules
include the backend SQL Server VM IP addresses, and the load balancer floating IP addresses for
the AG listener and the cluster core IP address, if applicable.