Problem

After recently setting up a SQL Availability Group my automatic and manual failovers were not working. When I attempted a manual failover I received the error “Failed to perform a manual failover of the availability group“…..“Failed to bring availability group xxx oline. The operation timed out”……“41131”

SQL Availability Group Failover 41131

Solution

To start with I used RDP to connect to one of the SQL server and ran the below PowerShell to download the Cluster logs which are far more useful that the displayed message.

Get-ClusterLog -Destination C:\temp
Get-ClusterLog

In the log for the secondary server the one I was attempting to fail over to I found the error “The use does not have permission to perform this action. (297)”

The use does not have permission to perform this action. (297)

I had previously had a similar permissions issue that had prevented me initially creating the availability group. I must of only applied the fix to the primary sever, after I ran the below SQL script on the secondary server my fail overs worked fine. The script gives the system user the required permissions to manage Availability Groups

GRANT ALTER ANY AVAILABILITY GROUP TO [NT AUTHORITY\SYSTEM];
GRANT CONNECT SQL TO [NT AUTHORITY\SYSTEM];
GRANT VIEW SERVER STATE TO [NT AUTHORITY\SYSTEM];