Cant add DB to Azure SQL DB Failover Group.

chrisrdba 471 Reputation points
2023-06-09T18:42:24.9333333+00:00

Greetings. When I try to add a DB to a failover group on an Azure SQL DB nothing happens. I click the Save button and get what's in the screen shot below, but the DB doesnt actually land on the Secondary server. Any ideas? Thanks!

fg

Azure SQL Database
SQL Server Other
{count} votes

1 answer

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2023-06-09T19:08:30.6933333+00:00

    As a workaround, could you try to create the failover group using PowerShell?

    $subscriptionId = "<SubscriptionID>"
    $resourceGroupName = "<Resource-Group-Name>"
    $location = "<Region>"
    $adminLogin = "<Admin-Login>"
    $password = "<Complex-Password>"
    $serverName = "<Primary-Server-Name>"
    $databaseName = "<Database-Name>"
    $drLocation = "<DR-Region>"
    $drServerName = "<Secondary-Server-Name>"
    $failoverGroupName = "<Failover-Group-Name>"
    
    # Create a secondary server in the failover region
    Write-host "Creating a secondary server in the failover region..."
    $drServer = New-AzSqlServer -ResourceGroupName $resourceGroupName `
       -ServerName $drServerName `
       -Location $drLocation `
       -SqlAdministratorCredentials $(New-Object -TypeName System.Management.Automation.PSCredential `
          -ArgumentList $adminlogin, $(ConvertTo-SecureString -String $password -AsPlainText -Force))
    $drServer
    
    # Create a failover group between the servers
    $failovergroup = Write-host "Creating a failover group between the primary and secondary server..."
    New-AzSqlDatabaseFailoverGroup `
       ResourceGroupName $resourceGroupName `
       -ServerName $serverName `
       -PartnerServerName $drServerName  `
       FailoverGroupName $failoverGroupName `
       FailoverPolicy Automatic `
       -GracePeriodWithDataLossHours 2
    $failovergroup
    
    # Add the database to the failover group
    Write-host "Adding the database to the failover group..."
    Get-AzSqlDatabase `
       -ResourceGroupName $resourceGroupName `
       -ServerName $serverName `
       -DatabaseName $databaseName | `
    Add-AzSqlDatabaseToFailoverGroup `
       -ResourceGroupName $resourceGroupName `
       -ServerName $serverName `
       -FailoverGroupName $failoverGroupName
    Write-host "Successfully added the database to the failover group..."
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.