Configure Availability Group Listener

Configure Availability Group Listener.

Availability Group Listener is a Virtual Network Name which provides client connectivity for Availability Group database on primary or secondary available replica.

In our scenario Server1 is PrimaryServer, Server2 SecondaryServer with automatic failover.

Here i am going to create Availability Group listener with name “AGSample” which points to Server1, in any case if PrimaryServer fails and SecondaryServer will work as Primary this listener automatically point to Server2.

Step1 : Expand Availability Group right click on “Avalability Group Listner” and select “Add Listener”.


Step2 : Provide Listener DNS Name “AGSample”.


Step3 : Open your Management Studio and provide “AGSample” in ServerName.


Now type “Select @@SERVERNAME” which gives “Server1” as result.

For testing, stop the SQL Server Service of  Server1, by doing this Server1 fails and Server2 come up as primary server.

Again open your Management Studio and provide “AGSample” in ServerName.

Now type “Select @@SERVERNAME” which gives “Server2” as result.

Availability Group Listener Connection String for application

“Server=tcp: AGSample,1433;Database=AGDatabase;IntegratedSecurity=SSPI”

Thanks & Regards,

Nirav Gajjar