You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
22
22
23
23
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.
24
24
25
25
## Prerequisites
26
26
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).
28
28
29
29
- 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).
32
32
33
33
## Add a secondary database
34
34
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.
36
36
37
37
To add a secondary database, you must be the subscription owner or co-owner.
38
38
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).
40
40
After the secondary is created and seeded, data begins replicating from the primary database to the new secondary database.
41
41
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).
43
43
44
-
> [!NOTE]
44
+
> [!NOTE]
45
45
> If the partner database already exists, (for example, as a result of terminating a previous geo-replication relationship) the command fails.
46
46
47
47
# [Portal](#tab/portal)
@@ -54,7 +54,7 @@ If your secondary replica is used _only_ for disaster recovery (DR) and doesn't
54
54
55
55
1. Select your geo-secondary database **Subscription** and **Resource group**.
56
56
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":::
58
58
59
59
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).
60
60
@@ -76,14 +76,14 @@ If your secondary replica is used _only_ for disaster recovery (DR) and doesn't
76
76
77
77
# [Azure CLI](#tab/azure-cli)
78
78
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:
80
80
81
81
- Your original Azure SQL database name.
82
82
- The Azure SQL server name.
83
83
- Your resource group name.
84
84
- The name of the server to create the new replica in.
85
85
86
-
> [!NOTE]
86
+
> [!NOTE]
87
87
> The secondary database must have the same service tier as the primary.
88
88
89
89
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
106
106
107
107
# [PowerShell](#tab/powershell)
108
108
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:
110
110
111
111
- Your original Azure SQL database name.
112
112
- The Azure SQL server name.
113
113
- Your resource group name.
114
114
- The name of the server to create the new replica in.
115
115
116
-
> [!NOTE]
116
+
> [!NOTE]
117
117
> The secondary database must have the same service tier as the primary.
118
118
119
119
You can select any region for your secondary server, but we recommend the [paired region](/azure/availability-zones/cross-region-replication-azure).
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:
142
141
143
142
```powershell
144
143
$parameters = @{
@@ -150,6 +149,7 @@ $parameters = @{
150
149
151
150
Get-AzSqlDatabaseReplicationLink @parameters
152
151
```
152
+
153
153
---
154
154
155
155
## Initiate a failover
@@ -188,12 +188,11 @@ $parameters = @{
188
188
Set-AzSqlDatabaseSecondary @parameters -Failover
189
189
```
190
190
191
-
---
192
191
---
193
192
194
193
The command immediately switches the secondary database into the primary role. This process normally should complete within 30 seconds or less.
195
194
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.
197
196
198
197
## Remove secondary database
199
198
@@ -204,8 +203,8 @@ This operation permanently stops the replication to the secondary database, and
204
203
1. In the [Azure portal](https://portal.azure.com), browse to the primary database in the geo-replication partnership.
205
204
1. Select **Replicas**.
206
205
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
+
209
208
# [Azure CLI](#tab/azure-cli)
210
209
211
210
Run the [az sql db replica delete-link](/cli/azure/sql/db/replica#az-sql-db-replica-delete-link) command.
- 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
241
239
242
240
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.
For more information, see [Azure SQL Database and Azure Synapse IP firewall rules](firewall-configure.md).
249
249
250
250
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.
251
251
252
252
```sql
253
-
create login geodrsetup with password ='ComplexPassword01';
253
+
CREATE LOGIN geodrsetup
254
+
WITH PASSWORD ='ComplexPassword01';
254
255
```
255
256
256
257
1. In the same database, create a user for the login, and add it to the `dbmanager` role:
257
258
258
259
```sql
259
-
createusergeodrsetup for login geodrsetup;
260
-
alter role dbmanager add member geodrsetup;
260
+
CREATEUSERgeodrsetup FOR LOGIN geodrsetup;
261
+
262
+
ALTER ROLE dbmanager ADD MEMBER geodrsetup;
261
263
```
262
264
263
265
1. Take note of the SID value of the new login. Obtain the SID value using the following query.
264
266
265
267
```sql
266
-
select sid fromsys.sql_loginswhere name ='geodrsetup';
268
+
SELECT sid
269
+
FROMsys.sql_logins
270
+
WHERE name ='geodrsetup';
267
271
```
268
272
269
273
1. Connect to the **primary** database (not the `master` database), and create a user for the same login.
270
274
271
275
```sql
272
-
createusergeodrsetupfor login geodrsetup;
276
+
CREATEUSERgeodrsetupFOR LOGIN geodrsetup;
273
277
```
274
278
275
279
1. In the same database, add the user to the `db_owner` role.
276
280
277
281
```sql
278
-
alter role db_owner add member geodrsetup;
282
+
ALTER ROLE db_owner ADD MEMBER geodrsetup;
279
283
```
280
284
281
285
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.
282
286
283
287
```sql
284
-
create login geodrsetup with password ='ComplexPassword01', sid=0x010600000000006400000000000000001C98F52B95D9C84BBBA8578FACE37C3E;
288
+
CREATE LOGIN geodrsetup
289
+
WITH PASSWORD ='ComplexPassword01', SID = 0x010600000000006400000000000000001C98F52B95D9C84BBBA8578FACE37C3E;
285
290
```
286
291
287
292
1. In the same database, create a user for the login, and add it to the `dbmanager` role.
288
293
289
294
```sql
290
-
createusergeodrsetup for login geodrsetup;
291
-
alter role dbmanager add member geodrsetup;
295
+
CREATEUSERgeodrsetup FOR LOGIN geodrsetup;
296
+
297
+
ALTER ROLE dbmanager ADD MEMBER geodrsetup;
292
298
```
293
299
294
300
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.
0 commit comments