Configure geo replication for Azure SQL Database

Estimated Time: 30 minutes

As a DBA within AdventureWorks, you need to enable geo-replication for Azure SQL Database, and ensure it is working properly. Additionally, you will manually fail it over to another region using the portal.

Note: These exercises may ask you to copy and paste T-SQL code and makes use of existing SQL resources. Please verify that the code has been copied correctly, before executing the code.

Enable geo-replication

  1. From the lab virtual machine, start a browser session and navigate to https://portal.azure.com. Connect to the Portal using the Azure Username and Password provided on the Resources tab for this lab virtual machine.

    Screenshot of Azure portal sign in page

  2. In the Azure portal, navigate to your database by searching for sql databases.

    Screenshot of searching for existing SQL databases.

  3. Select the SQL database AdventureWorksLT.

    Screenshot of selecting the AdventureWorks SQL database.

  4. On the blade for the database, in Data management section, select Replicas.

    Screenshot showing selecting Geo-Replication.

  5. Select + Create replica.

    Screenshot showing selecting Geo-Replication page.

  6. On the Create SQL Database - Geo Replica page and under Server, select the Create New link.

    Screenshot showing Create New server link.

    [!NOTE] As we are creating a new server to host our secondary database, we can ignore the error message above.

  7. On the Create SQL Database Server page, enter a unique server name of your preference, a valid server admin login, and a secure password. Select a location as the target region, and then select OK to create the server.

    Screenshot showing the Create SQL Database Server page.

  8. Back in to the Create SQL Database - Geo Replica page, select Review + Create.

    Screenshot showing the Create SQL Database Server page.

  9. Select Create.

    Screenshot showing the review and create page.

  10. The secondary server and the database will now be created. To check the status, look under the notification icon at the top of the portal.

    Screenshot showing the review and create page.

  11. If successful, it will progress from Deployment in progress to Deployment succeeded.

    Screenshot showing the review and create page.

Failover SQL Database to a secondary region

Now that the Azure SQL Database replica is created, you will perform a failover.

  1. Navigate to the SQL servers page, and notice the new server in the list. Select the secondary server (you may have a different server name).

    Screenshot showing SQL servers page.

  2. On the blade for the SQL server, in Settings section, select SQL databases.

    Screenshot showing SQL databases option.

  3. On the SQL database main blade, in Data management section, select Replicas.

    Screenshot showing selecting Geo-Replication.

  4. Note that the geo replication link is now established.

    Screenshot showing the Replicas option.

  5. Select the menu for the secondary server, and select Forced Failover.

    Screenshot showing the forced failover option.

    [!NOTE] Forced failover will switch the secondary database to the primary role. All sessions are disconnected during this operation.

  6. When prompted by the warning message, click Yes.

    Screenshot showing a forced failover warning message.

  7. The status of the primary replica will switch to Pending and the secondary to Failover.

    Screenshot showing a forced failover warning message.

    [!NOTE] This process can take a few minutes. When complete, the roles will switch with the secondary becoming the new primary, and the old primary the secondary.

We’ve seen the readable secondary database may be in the same Azure region as the primary, or, more commonly, in a different region. This kind of readable secondary databases are also known as geo-secondaries, or geo-replicas.

You have now seen how to enable geo-replicas for Azure SQL Database, and manually fail it over to another region using the portal.