The Availability Group listener is an IP address and network name that the SQL Server Availability Group listens on. To create the Availability Group listener, do the following steps:
-
Make the SQL Server availability group resource dependent on the client access point
-
Make the client access point resource dependent on the IP address.
The following sections provide detailed instructions for each of these steps.
-
Use RDP to connect to the Azure virtual machine that hosts the primary replica.
-
Open Failover Cluster Manager.
-
Select the Networks node, and note the cluster network name. Use this name in the
$ClusterNetworkName
variable in the PowerShell script.In the following picture the cluster network name is Cluster Network 1:
The client access point is the network name that applications use to connect to the databases in an availability group. Create the client access point in Failover Cluster Manager.
-
Expand the cluster name, and then click Roles.
-
In the Roles pane, right-click the Availability Group name and then select Add Resource > Client Access Point.
-
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.
To finish creating the listener, click Next twice, and then click Finish. Do not bring the listener or resource online at this point.
-
Click the Resources tab, then expand the client access point you created. The client access point is offline.
-
Right-click the IP resource and click properties. Note the name of the IP address. Use this name in the
$IPResourceName
variable in the PowerShell script. -
Under IP Address, click Static IP Address. Set the IP address to the same address that you used when you set the load balancer address on the Azure portal.
-
In Failover Cluster Manager, click Roles and click your Availability Group.
-
On the Resources tab, right-click the availability resource group under Server Name and click Properties.
-
On the dependencies tab, add the name resource. This resource is the client access point.
-
Click OK.
-
In Failover Cluster Manager, click Roles and click your Availability Group.
-
On the Resources tab, right-click the client access point resource under Server Name and click Properties.
-
Click the Dependencies tab. Set a dependency on the listener resource name. If there are multiple resources listed, verify that the IP addresses have OR, not AND, dependencies. Click OK.
-
Right-click the listener name and click Bring Online.
-
Copy the following PowerShell script to one of your SQL Servers. Update the variables for your environment.
$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 $ILBIP = “<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]$ProbePort = <nnnnn> Import-Module FailoverClusters Get-ClusterResource $IPResourceName | Set-ClusterParameter -Multiple @{"Address"="$ILBIP";"ProbePort"=$ProbePort;"SubnetMask"="255.255.255.255";"Network"="$ClusterNetworkName";"EnableDhcp"=0}
-
Set the cluster parameters by running the PowerShell script on one of the cluster nodes.
Note
If your SQL Servers are in separate regions, you need to run the PowerShell script twice. The first time, use the $ILBIP
and $ProbePort
from the first region. The second time, use the $ILBIP
and $ProbePort
from the second region. The cluster network name, and the cluster IP resource name are the same.