-> When trying to open a new query window for a secondary database that is part of Availability group using SQL Server Management Studio, I got below error,
TITLE: Connect to Database Engine
The target database (‘JBDB’) is in an availability group and is currently accessible for connections when the application intent is set to read only. For more information about application intent, see SQL Server Books Online. (Microsoft SQL Server, Error: 978)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=978&LinkId=20476
-> I just configured Read-Routing list on the Primary database that is part of Always On availability group. More details on Read-Routing list can be found here.
-> Below are options that can be leveraged when configuring Read-Only Access on an Availability group,
No user connections are allowed to secondary databases of this replica. They are not available for read access. This is the default setting.
Only read-only connections are allowed to secondary databases of this replica. The secondary database(s) are all available for read access.
All connections are allowed to secondary databases of this replica, but only for read access. The secondary database(s) are all available for read access.
-> More details of these option are explained in this blog post with more clarity.
-> The error that we are experiencing is due to the fact that the Availability group is configured with “Read-intent only” option.
-> “Read-intent only” means that the Secondary Replica only accepts connections that are explicitly configured for that purpose and the problem occurs when you are trying to connect to an AG Secondary Replica database configured for Read-Intent only without explicitly using the proper parameter.
-> It is pretty clear that we are not able to make a connection to database JBDB on Server JBSAG2 directly. Let us try a connection using ApplicationIntent=ReadOnly and it should connect just fine,
-> If you don’t want to use this switch and want to directly connect to the secondary database to execute Read-Only Queries using SSMS or other application, then configuring Readabale Secondary to “Yes” instead of “Read-intent only” on Availability group properties as below will help,
Hope this helps!!!
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.