Q: I want to offload some of my reporting workload to an AlwaysOn replica. How can I configure my AlwaysOn replica to allow read-only access?

A: While the primary replica allows read-write access by default, no connections are allowed to secondary replicas. If you want to a read-only SQL Server AlwaysOn replica, you need to specify the ALLOW_CONNECTIONS=READ_ONLY keyword or the secondary replica.

The following T-SQL example shows how you can add a read-enabled secondary replica to an existing AlwaysOn Availability group named MYSQLServerAG on the host named ORPORTSQL01.

  1. ALTER AVAILABILITY GROUP MySQLServerAG
  2.    ADD REPLICA ON
  3.       'ORPORTSQL01' WITH
  4.          (
  5.          ENDPOINT_URL = 'TCP://ORPORTSQL01:7022',
  6.          PRIMARY_ROLE ( ALLOW_CONNECTIONS = READ_WRITE ),
  7.          SECONDARY_ROLE (ALLOW_CONNECTIONS = READ_ONLY )
  8.          );
  9. GO

Related: Microsoft SQL Server 2012: AlwaysOn Availability Groups Feature