Skip to content

Commit 1ee9e49

Browse files
committed
Refresh Geo-replication & failover tutorial
1 parent 53dbd91 commit 1ee9e49

File tree

1 file changed

+48
-43
lines changed

1 file changed

+48
-43
lines changed

azure-sql/database/active-geo-replication-configure-portal.md

+48-43
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ title: "Tutorial: Geo-replication & failover in portal"
33
description: Learn how to configure geo-replication for an SQL database using the Azure portal or Azure CLI, and initiate failover.
44
author: rajeshsetlem
55
ms.author: rsetlem
6-
ms.reviewer: wiassaf, mathoma
7-
ms.date: 09/26/2024
6+
ms.reviewer: wiassaf, mathoma, randolphwest
7+
ms.date: 10/08/2024
88
ms.service: azure-sql-database
99
ms.subservice: high-availability
1010
ms.topic: tutorial
@@ -16,32 +16,32 @@ ms.custom:
1616
---
1717
# Tutorial: Configure active geo-replication and failover (Azure SQL Database)
1818

19-
[!INCLUDE[appliesto-sqldb](../includes/appliesto-sqldb.md)]
19+
[!INCLUDE [appliesto-sqldb](../includes/appliesto-sqldb.md)]
2020

2121
This article shows you how to configure [active geo-replication](active-geo-replication-overview.md) and initiate a failover for Azure SQL Database by using the [Azure portal](https://portal.azure.com), PowerShell, or the Azure CLI.
2222

2323
Active geo-replication is configured per database. To fail over a group of databases, or if your application requires a stable connection endpoint, consider [Failover groups](failover-group-sql-db.md) instead.
2424

2525
## Prerequisites
2626

27-
- To complete this tutorial, you need a single Azure SQL Database. To learn how to create a single database with Azure portal, Azure CLI, or PowerShell, see [Quickstart: Create a single database - Azure SQL Database](single-database-create-quickstart.md?view=azuresql&preserve-view=true&tabs=azure-powershell).
27+
- To complete this tutorial, you need a single Azure SQL Database. To learn how to create a single database with Azure portal, Azure CLI, or PowerShell, see [Quickstart: Create a single database - Azure SQL Database](single-database-create-quickstart.md?view=azuresql&preserve-view=true&tabs=azure-powershell).
2828

2929
- You can use the Azure portal to set up Active geo replication across subscriptions as long as both the subscriptions are in the same Microsoft Entra ID tenant.
30-
- To create a geo-secondary replica in a subscription *different* from the subscription of the primary in a different Microsoft Entra ID tenant, use [the geo-secondary across subscriptions and Microsoft Entra ID tenant T-SQL tutorial](#cross-subscription-geo-replication).
31-
- Cross-subscription geo-replication operations including setup and geo-failover are also supported using [Databases Create or Update REST API](/rest/api/sql/databases/create-or-update).
30+
- To create a geo-secondary replica in a subscription *different* from the subscription of the primary in a different Microsoft Entra ID tenant, use [the geo-secondary across subscriptions and Microsoft Entra ID tenant T-SQL tutorial](#cross-subscription-geo-replication).
31+
- Cross-subscription geo-replication operations including setup and geo-failover are also supported using [Databases Create or Update REST API](/rest/api/sql/databases/create-or-update).
3232

3333
## Add a secondary database
3434

35-
The following steps create a new secondary database in a geo-replication partnership.
35+
The following steps create a new secondary database in a geo-replication partnership.
3636

3737
To add a secondary database, you must be the subscription owner or co-owner.
3838

39-
The secondary database has the same name as the primary database and has, by default, the same service tier and compute size. The secondary database can be a single database or a pooled database. For more information, see [DTU-based purchasing model](service-tiers-dtu.md) and [vCore-based purchasing model](service-tiers-vcore.md).
39+
The secondary database has the same name as the primary database and has, by default, the same service tier and compute size. The secondary database can be a single database or a pooled database. For more information, see [DTU-based purchasing model overview](service-tiers-dtu.md) and [vCore-based purchasing model](service-tiers-vcore.md).
4040
After the secondary is created and seeded, data begins replicating from the primary database to the new secondary database.
4141

42-
If your secondary replica is used _only_ for disaster recovery (DR) and doesn't have any read or write workloads, you can save on licensing costs by designating the database for standby when you configure a new active geo-replication relationship. For more information, see [license-free standby replica](standby-replica-how-to-configure.md).
42+
If your secondary replica is used *only* for disaster recovery (DR), and doesn't have any read or write workloads, you can save on licensing costs by designating the database for standby when you configure a new active geo-replication relationship. For more information, see [license-free standby replica](standby-replica-how-to-configure.md).
4343

44-
> [!NOTE]
44+
> [!NOTE]
4545
> If the partner database already exists, (for example, as a result of terminating a previous geo-replication relationship) the command fails.
4646
4747
# [Portal](#tab/portal)
@@ -54,7 +54,7 @@ If your secondary replica is used _only_ for disaster recovery (DR) and doesn't
5454

5555
1. Select your geo-secondary database **Subscription** and **Resource group**.
5656

57-
:::image type="content" source="media/active-geo-replication-configure-portal/subscription-resource-group.png" alt-text="Screenshot from the Azure portal of the subscription and resource group.":::
57+
:::image type="content" source="media/active-geo-replication-configure-portal/subscription-resource-group.png" alt-text="Screenshot from the Azure portal of the subscription and resource group." lightbox="media/active-geo-replication-configure-portal/subscription-resource-group.png":::
5858

5959
1. Select or create the server for the secondary database, and configure the **Compute + storage** options if necessary. You can select any region for your secondary server, but we recommend the [paired region](/azure/availability-zones/cross-region-replication-azure).
6060

@@ -76,14 +76,14 @@ If your secondary replica is used _only_ for disaster recovery (DR) and doesn't
7676

7777
# [Azure CLI](#tab/azure-cli)
7878

79-
Select the database you want to set up for geo-replication. You'll need the following information:
79+
Select the database you want to set up for geo-replication. You need the following information:
8080

8181
- Your original Azure SQL database name.
8282
- The Azure SQL server name.
8383
- Your resource group name.
8484
- The name of the server to create the new replica in.
8585

86-
> [!NOTE]
86+
> [!NOTE]
8787
> The secondary database must have the same service tier as the primary.
8888
8989
You can select any region for your secondary server, but we recommend the [paired region](/azure/availability-zones/cross-region-replication-azure).
@@ -106,14 +106,14 @@ az sql db replica list-links --name guestlist --resource-group ContosoHotel --se
106106

107107
# [PowerShell](#tab/powershell)
108108

109-
Select the database you want to set up for geo-replication. You'll need the following information:
109+
Select the database you want to set up for geo-replication. You need the following information:
110110

111111
- Your original Azure SQL database name.
112112
- The Azure SQL server name.
113113
- Your resource group name.
114114
- The name of the server to create the new replica in.
115115

116-
> [!NOTE]
116+
> [!NOTE]
117117
> The secondary database must have the same service tier as the primary.
118118
119119
You can select any region for your secondary server, but we recommend the [paired region](/azure/availability-zones/cross-region-replication-azure).
@@ -127,18 +127,17 @@ Set-AzContext -SubscriptionId $subscriptionid
127127
128128
$parameters = @{
129129
ResourceGroupName = 'PrimaryRG'
130-
ServerName = 'PrimaryServer'
131-
DatabaseName = 'TestDB'
130+
ServerName = 'PrimaryServer'
131+
DatabaseName = 'TestDB'
132132
PartnerResourceGroupName = 'SecondaryRG'
133133
PartnerServerName = 'SecondaryServer'
134134
PartnerDatabaseName = 'TestDB'
135135
}
136136
137137
New-AzSqlDatabaseSecondary @parameters
138-
139138
```
140139

141-
When the deployment is complete, you can check the status of the secondary database by running the `Get-AzSqlDatabaseReplicationLink` command:
140+
When the deployment is complete, you can check the status of the secondary database by running the `Get-AzSqlDatabaseReplicationLink` command:
142141

143142
```powershell
144143
$parameters = @{
@@ -150,6 +149,7 @@ $parameters = @{
150149
151150
Get-AzSqlDatabaseReplicationLink @parameters
152151
```
152+
153153
---
154154

155155
## Initiate a failover
@@ -188,12 +188,11 @@ $parameters = @{
188188
Set-AzSqlDatabaseSecondary @parameters -Failover
189189
```
190190

191-
---
192191
---
193192

194193
The command immediately switches the secondary database into the primary role. This process normally should complete within 30 seconds or less.
195194

196-
There's a short period during which both databases are unavailable, on the order of 0 to 25 seconds, while the roles are switched. If the primary database has multiple secondary databases, the command automatically reconfigures the other secondaries to connect to the new primary. The entire operation should take less than a minute to complete under normal circumstances.
195+
Both databases are unavailable, for up to 25 seconds, while the roles are switched. If the primary database has multiple secondary databases, the command automatically reconfigures the other secondaries to connect to the new primary. The entire operation should take less than a minute to complete under normal circumstances.
197196

198197
## Remove secondary database
199198

@@ -204,8 +203,8 @@ This operation permanently stops the replication to the secondary database, and
204203
1. In the [Azure portal](https://portal.azure.com), browse to the primary database in the geo-replication partnership.
205204
1. Select **Replicas**.
206205
1. In the **Geo replicas** list, select the database you want to remove from the geo-replication partnership, select the ellipsis, and then select **Stop replication**.
207-
1. A confirmation window opens. Select **Yes** to remove the database from the geo-replication partnership. (Set it to a read-write database not part of any replication.)
208-
206+
1. A confirmation window opens. Select **Yes** to remove the database from the geo-replication partnership. (Set it to a read-write database that isn't part of any replication.)
207+
209208
# [Azure CLI](#tab/azure-cli)
210209

211210
Run the [az sql db replica delete-link](/cli/azure/sql/db/replica#az-sql-db-replica-delete-link) command.
@@ -236,59 +235,66 @@ Remove-AzSqlDatabaseSecondary @parameters
236235
## Cross-subscription geo-replication
237236

238237
- To create a geo-secondary replica in a subscription *different* from the subscription of the primary in the *same* Microsoft Entra tenant, you can use the Azure portal or the steps in this section.
239-
- To create a geo-secondary replica in a subscription *different* from the subscription of the primary in a different Microsoft Entra tenant, you must use SQL authentication and T-SQL as described in the steps in this section. [Microsoft Entra authentication](authentication-aad-overview.md) for cross-subscription geo-replication is not supported when a logical server is in a different Azure tenant
240-
238+
- To create a geo-secondary replica in a subscription *different* from the subscription of the primary in a different Microsoft Entra tenant, you must use SQL authentication and T-SQL as described in the steps in this section. [Microsoft Entra authentication for Azure SQL](authentication-aad-overview.md) for cross-subscription geo-replication isn't supported when a logical server is in a different Azure tenant
241239

242240
1. Add the IP address of the client machine executing the T-SQL commands in this example, to the server firewalls of **both** the primary and secondary servers. You can confirm that IP address by executing the following query while connected to the primary server from the same client machine.
243-
241+
244242
```sql
245-
select client_net_address from sys.dm_exec_connections where session_id = @@SPID;
246-
```
243+
SELECT client_net_address
244+
FROM sys.dm_exec_connections
245+
WHERE session_id = @@SPID;
246+
```
247247

248248
For more information, see [Azure SQL Database and Azure Synapse IP firewall rules](firewall-configure.md).
249249

250250
1. In the `master` database on the **primary** server, create a SQL authentication login dedicated to active geo-replication setup. Adjust login name and password as needed.
251251

252252
```sql
253-
create login geodrsetup with password = 'ComplexPassword01';
253+
CREATE LOGIN geodrsetup
254+
WITH PASSWORD = 'ComplexPassword01';
254255
```
255256

256257
1. In the same database, create a user for the login, and add it to the `dbmanager` role:
257258

258259
```sql
259-
create user geodrsetup for login geodrsetup;
260-
alter role dbmanager add member geodrsetup;
260+
CREATE USER geodrsetup FOR LOGIN geodrsetup;
261+
262+
ALTER ROLE dbmanager ADD MEMBER geodrsetup;
261263
```
262264

263265
1. Take note of the SID value of the new login. Obtain the SID value using the following query.
264266

265267
```sql
266-
select sid from sys.sql_logins where name = 'geodrsetup';
268+
SELECT sid
269+
FROM sys.sql_logins
270+
WHERE name = 'geodrsetup';
267271
```
268272

269273
1. Connect to the **primary** database (not the `master` database), and create a user for the same login.
270274

271275
```sql
272-
create user geodrsetup for login geodrsetup;
276+
CREATE USER geodrsetup FOR LOGIN geodrsetup;
273277
```
274278

275279
1. In the same database, add the user to the `db_owner` role.
276280

277281
```sql
278-
alter role db_owner add member geodrsetup;
282+
ALTER ROLE db_owner ADD MEMBER geodrsetup;
279283
```
280284

281285
1. In the `master` database on the **secondary** server, create the same login as on the primary server, using the same name, password, and SID. Replace the hexadecimal SID value in the sample command below with the one obtained in Step 4.
282286

283287
```sql
284-
create login geodrsetup with password = 'ComplexPassword01', sid=0x010600000000006400000000000000001C98F52B95D9C84BBBA8578FACE37C3E;
288+
CREATE LOGIN geodrsetup
289+
WITH PASSWORD = 'ComplexPassword01', SID = 0x010600000000006400000000000000001C98F52B95D9C84BBBA8578FACE37C3E;
285290
```
286291

287292
1. In the same database, create a user for the login, and add it to the `dbmanager` role.
288293

289294
```sql
290-
create user geodrsetup for login geodrsetup;
291-
alter role dbmanager add member geodrsetup;
295+
CREATE USER geodrsetup FOR LOGIN geodrsetup;
296+
297+
ALTER ROLE dbmanager ADD MEMBER geodrsetup;
292298
```
293299

294300
1. Connect to the `master` database on the **primary** server using the new `geodrsetup` login, and initiate geo-secondary creation on the secondary server. Adjust database name and secondary server name as needed. Once the command is executed, you can monitor geo-secondary creation by querying the [sys.dm_geo_replication_link_status](/sql/relational-databases/system-dynamic-management-views/sys-dm-geo-replication-link-status-azure-sql-database) view in the **primary** database, and the [sys.dm_operation_status](/sql/relational-databases/system-dynamic-management-views/sys-dm-operation-status-azure-sql-database) view in the `master` database on the **primary** server. The time needed to create a geo-secondary depends on the primary database size.
@@ -299,10 +305,9 @@ Remove-AzSqlDatabaseSecondary @parameters
299305

300306
1. After the geo-secondary is successfully created, the users, logins, and firewall rules created by this procedure can be removed.
301307

302-
## Next steps
303-
304-
* [Active geo-replication](active-geo-replication-overview.md).
305-
* [Failover groups](failover-group-sql-db.md)
306-
* [Business continuity overview](business-continuity-high-availability-disaster-recover-hadr-overview.md).
307-
* Save on licensing costs by designating your secondary DR replica for [standby](standby-replica-how-to-configure.md).
308+
## Related content
308309

310+
- [Active geo-replication](active-geo-replication-overview.md)
311+
- [Failover groups overview & best practices (Azure SQL Database)](failover-group-sql-db.md)
312+
- [Overview of business continuity with Azure SQL Database](business-continuity-high-availability-disaster-recover-hadr-overview.md)
313+
- [Configure a license-free standby replica for Azure SQL Database](standby-replica-how-to-configure.md)

0 commit comments

Comments
 (0)