Skip to content

Commit 5fb4ed6

Browse files
authored
Merge pull request #220849 from WilliamDAssafMSFT/20221217-restore-cross-tenant-ambika
20221217 restore cross tenant dedicated SQL pool
2 parents ffcfa36 + a42ed40 commit 5fb4ed6

File tree

2 files changed

+160
-10
lines changed

2 files changed

+160
-10
lines changed

articles/synapse-analytics/backuprestore/restore-sql-pool.md

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ manager: joannapea
66
ms.service: synapse-analytics
77
ms.topic: how-to
88
ms.subservice: sql
9-
ms.date: 10/07/2022
9+
ms.date: 12/07/2022
1010
ms.author: stevehow
11-
ms.reviewer: joanpo
11+
ms.reviewer: joanpo, wiassaf
1212
ms.custom: seo-lt-2019, engagement-fy23
1313
---
1414

@@ -36,7 +36,7 @@ In this article, you learn how to restore an existing dedicated SQL pool in Azur
3636

3737
* If the dedicated SQL pool doesn't have any automatic restore points, wait a few hours, or create a user defined restore point before restoring. For User-Defined Restore Points, select an existing one or create a new one.
3838

39-
* If you want to restore a dedicated SQL pool from a different workspace, select **New dedicated SQL pool** from your current workspace. Under the **Additional settings** tab find the **Use existing data** and select the **Restore point** option. As shown in the above screenshot, you can then select the **Server or workspace** name from which you can restore.
39+
* If you want to restore a dedicated SQL pool from a different workspace, select **New dedicated SQL pool** from your current workspace. Under the **Additional settings** tab, find the **Use existing data** and select the **Restore point** option. As shown in the above screenshot, you can then select the **Server or workspace** name from which you can restore.
4040

4141
* If you are restoring a geo-backup, select the workspace located in the source region and the dedicated SQL pool you want to restore.
4242

@@ -206,6 +206,95 @@ $RestoredDatabase.status
206206
207207
```
208208

209+
## Restore an existing dedicated SQL pool to a different tenant through PowerShell
210+
211+
When performing a cross-tenant-subscription restore, a dedicated SQL pool in an Azure Synapse workspace can only restore directly to a standalone dedicated SQL pool (formerly SQL DW). If it is required to restore a dedicated SQL pool in an Azure Synapse workspace to a workspace in the destination subscription across a different tenant, an additional restore step is required.
212+
213+
For cross-tenant-subscription restore, the user must have a '(Guest)' account with either the 'Owner' or 'Contributor' access permissions to the destination tenant to which the dedicated SQL pool (formerly SQL DW) will be restored to.
214+
215+
The following PowerShell script for cross-tenant restore works in the same way as a cross-subscription restore when the user is given '(Guest)' access to the destination tenant.
216+
217+
Steps:
218+
219+
1. Open a PowerShell terminal.
220+
1. Update Az.Sql Module to 3.8.0 (or greater) using `Update-Module`.
221+
1. Connect to your Azure account using `Connect-AzAccount`.
222+
1. List all the subscriptions associated with your account along with its Tenant ID. Select the subscription that contains the dedicated SQL pool to be restored.
223+
1. List the restore points for the dedicated SQL pool using `Get-AzSynapseSqlPoolRestorePoint`.
224+
1. Pick the desired restore point, setting the variable `$PointInTime`.
225+
1. In the destination tenant, make sure your user has guest access with either 'Owner' or 'Contributor' permissions.
226+
1. Select the destination subscription along with the corresponding Tenant ID to which the dedicated SQL pool should be restored.
227+
1. Restore the dedicated SQL pool to the desired restore point using `Restore-AzSqlDatabase`.
228+
1. Verify that the restored dedicated SQL pool (formerly SQL DW) is online.
229+
1. If the desired destination is a Synapse workspace, uncomment the code to perform the additional restore step.
230+
1. Create a restore point for the newly created data warehouse.
231+
1. Retrieve the last restore point created by using the `Select -Last 1` syntax.
232+
1. Perform the restore to the desired Azure Synapse workspace.
233+
234+
235+
```powershell
236+
$SourceTenantID="<YourSourceTenantID>" # like '00000000-0000-0000-0000-000000000000'
237+
$SourceSubscriptionName="<YourSubscriptionName>"
238+
$SourceResourceGroupName="<YourResourceGroupName>"
239+
$SourceWorkspaceName="<YourServerNameWithoutURLSuffixSeeNote>" # Without sql.azuresynapse.net
240+
$SourceSQLPoolName="<YourDatabaseName>"
241+
$TargetTenantID="<YourTargetTenantID>" # like '00000000-0000-0000-0000-000000000000'
242+
$TargetSubscriptionName="<YourTargetSubscriptionName>"
243+
$TargetResourceGroupName="<YourTargetResourceGroupName>"
244+
$TargetServerName="<YourTargetServerNameWithoutURLSuffixSeeNote>" # Without sql.azuresynapse.net
245+
$TargetDatabaseName="<YourDatabaseName>"
246+
#$TargetWorkspaceName="<YourTargetWorkspaceName>" # uncomment if restore to an Azure Synapse workspace is required
247+
248+
# Update Az.Sql module to the latest version (3.8.0 or above)
249+
# Update-Module -Name Az.Sql
250+
251+
Connect-AzAccount
252+
Get-AzSubscription
253+
Select-AzSubscription -SubscriptionName $SourceSubscriptionName
254+
255+
# Set content to the source subscription and tenant
256+
Set-AzContext -Subscription $SourceSubscriptionName -Tenant $SourceTenantID
257+
258+
# list all restore points
259+
Get-AzSynapseSqlPoolRestorePoint -ResourceGroupName $SourceResourceGroupName -WorkspaceName $SourceWorkspaceName -Name $SourceSQLPoolName
260+
# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
261+
$PointInTime="<RestorePointCreationDate>"
262+
263+
# Get the specific SQL pool to restore
264+
$SQLPool = Get-AzSynapseSqlPool -ResourceGroupName $SourceResourceGroupName -WorkspaceName $SourceWorkspaceName -Name $SourceSQLPoolName
265+
# Transform Synapse SQL pool resource ID to SQL database ID because currently the restore command only accepts the SQL database ID format.
266+
$DatabaseID = $SQLPool.Id -replace "Microsoft.Synapse", "Microsoft.Sql" `
267+
-replace "workspaces", "servers" `
268+
-replace "sqlPools", "databases"
269+
270+
# Switch context to the destination subscription and tenant
271+
Set-AzContext -Subscription $TargetSubscriptionName -Tenant $TargetTenantID
272+
273+
# Restore database from a desired restore point of the source database to the target server in the desired subscription
274+
$RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTime $PointInTime -ResourceGroupName $TargetResourceGroupName `
275+
-ServerName $TargetServerName -TargetDatabaseName $TargetDatabaseName –ResourceId $DatabaseID
276+
277+
# Verify the status of restored database
278+
$RestoredDatabase.status
279+
280+
# uncomment below cmdlets to perform one more restore to push the dedicated SQL pool to an existing workspace in the destination subscription
281+
282+
# # Create restore point
283+
# New-AzSqlDatabaseRestorePoint -ResourceGroupName $RestoredDatabase.ResourceGroupName -ServerName $RestoredDatabase.ServerName `
284+
# -DatabaseName $RestoredDatabase.DatabaseName -RestorePointLabel "UD-001"
285+
286+
# # Gets the last restore point of the dedicated SQL pool (formerly SQL DW) (will use the RestorePointCreationDate property)
287+
# $RestorePoint = Get-AzSqlDatabaseRestorePoint -ResourceGroupName $RestoredDatabase.ResourceGroupName -ServerName $RestoredDatabase.ServerName `
288+
# -DatabaseName $RestoredDatabase.DatabaseName | Select -Last 1
289+
290+
# # Restore to destination synapse workspace
291+
# # Set performance level as desired
292+
# $FinalRestore = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $RestorePoint.RestorePointCreationDate -ResourceGroupName $TargetResourceGroupName `
293+
# -WorkspaceName $TargetWorkspaceName -TargetSqlPoolName $TargetDatabaseName –ResourceId $RestoredDatabase.ResourceID -PerformanceLevel DW100c
294+
295+
```
296+
297+
209298
## Troubleshooting
210299
A restore operation can result in a deployment failure based on a "RequestTimeout" exception.
211300

@@ -219,3 +308,4 @@ This timeout can be ignored. Review the dedicated SQL pool page in the Azure por
219308

220309
- [Create a restore point](sqlpool-create-restore-point.md)
221310
- [Restore-AzSqlDatabase](/powershell/module/az.sql/restore-azsqldatabase?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json)
311+
- [What's the difference between Azure Synapse (formerly SQL DW) and Azure Synapse Analytics Workspace](https://techcommunity.microsoft.com/t5/azure-synapse-analytics-blog/what-s-the-difference-between-azure-synapse-formerly-sql-dw-and/ba-p/3597772)

articles/synapse-analytics/sql-data-warehouse/sql-data-warehouse-restore-active-paused-dw.md

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ manager: joannapea
66
ms.service: synapse-analytics
77
ms.topic: conceptual
88
ms.subservice: sql-dw
9-
ms.date: 04/11/2022
10-
ms.author: stevehow
11-
ms.reviewer: joannapea
9+
ms.date: 12/07/2022
10+
ms.author: ajagadish
11+
ms.reviewer: joannapea, wiassaf
1212
ms.custom: seo-lt-2019, devx-track-azurepowershell
1313
---
1414

@@ -18,7 +18,7 @@ In this article, you learn how to restore an existing dedicated SQL pool (former
1818

1919
[!INCLUDE [updated-for-az](../../../includes/updated-for-az.md)]
2020

21-
**Verify your DTU capacity.** Each pool is hosted by a [logical SQL server](/azure/azure-sql/database/logical-servers) (for example, myserver.database.windows.net) which has a default DTU quota. Verify the server has enough remaining DTU quota for the database being restored. To learn how to calculate DTU needed or to request more DTU, see [Request a DTU quota change](sql-data-warehouse-get-started-create-support-ticket.md).
21+
**Verify your DTU capacity.** Each pool is hosted by a [logical SQL server](/azure/azure-sql/database/logical-servers) (for example, `myserver.database.windows.net`) which has a default DTU quota. Verify the server has enough remaining DTU quota for the database being restored. To learn how to calculate DTU needed or to request more DTU, see [Request a DTU quota change](sql-data-warehouse-get-started-create-support-ticket.md).
2222

2323
## Before you begin
2424

@@ -85,12 +85,12 @@ $RestoredDatabase.status
8585
## Restore an existing dedicated SQL pool (formerly SQL DW) through the Azure portal
8686

8787
1. Sign in to the [Azure portal](https://portal.azure.com/).
88-
2. Navigate to the dedicated that you want to restore from.
89-
3. At the top of the Overview blade, select **Restore**.
88+
2. Navigate to the dedicated SQL pool that you want to restore from.
89+
3. At the top of the **Overview** page, select **Restore**.
9090

9191
![ Restore Overview](./media/sql-data-warehouse-restore-active-paused-dw/restoring-01.png)
9292

93-
4. Select either **Automatic Restore Points** or **User-Defined Restore Points**. If the dedicated SQL pool (formerly SQL DW) doesn't have any automatic restore points, wait a few hours or create a user defined restore point before restoring. For User-Defined Restore Points, select an existing one or create a new one. For **Server**, you can pick a server in a different resource group and region or create a new one. After providing all the parameters, click **Review + Restore**.
93+
4. Select either **Automatic Restore Points** or **User-Defined Restore Points**. If the dedicated SQL pool (formerly SQL DW) doesn't have any automatic restore points, wait a few hours or create a user defined restore point before restoring. For User-Defined Restore Points, select an existing one or create a new one. For **Server**, you can pick a server in a different resource group and region or create a new one. After providing all the parameters, select **Review + Restore**.
9494

9595
![Automatic Restore Points](./media/sql-data-warehouse-restore-active-paused-dw/restoring-11.png)
9696

@@ -150,6 +150,66 @@ $RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTim
150150
$RestoredDatabase.status
151151
```
152152

153+
## Restore an existing dedicated SQL pool (formerly SQL DW) to a different tenant through PowerShell
154+
155+
This is similar guidance to cross subscription restore. However the below instructions show that [Get-AzSqlDatabase](/powershell/module/az.sql/Get-AzSqlDatabase?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json) PowerShell cmdlet should be performed in the originating tenant while the [Restore-AzSqlDatabase](/powershell/module/az.sql/restore-azsqldatabase?toc=/azure/synapse-analytics/sql-data-warehouse/toc.json&bc=/azure/synapse-analytics/sql-data-warehouse/breadcrumb/toc.json) PowerShell cmdlet should be performed in the destination tenant.
156+
157+
Note that the user performing the restore must have proper permissions in both the source and target tenants. At the destination tenant, the user must have a '(Guest)' account with either the 'Owner' or 'Contributor' access permissions to which the dedicated SQL pool (formerly SQL DW) will be restored to.
158+
159+
The following PowerShell script for cross-tenant restore works in the same way as a cross-subscription restore when the user is given '(Guest)' access to the destination tenant.
160+
161+
> [!NOTE]
162+
> If you intend to restore your dedicated SQL pool (formerly SQL DW) to a Synapse workspace, use the additional PowerShell steps provided in [Restore an existing dedicated SQL pool](../backuprestore/restore-sql-pool.md). For more information on the differences between dedicated SQL pools, see [What's the difference between Azure Synapse (formerly SQL DW) and Azure Synapse Analytics Workspace](https://techcommunity.microsoft.com/t5/azure-synapse-analytics-blog/what-s-the-difference-between-azure-synapse-formerly-sql-dw-and/ba-p/3597772).
163+
164+
1. Open a PowerShell terminal.
165+
1. Update Az.Sql Module to 3.8.0 (or greater) using `Update-Module`.
166+
1. Connect to your Azure account using `Connect-AzAccount`.
167+
1. List all the subscriptions associated with your account along with its Tenant ID. Select the subscription that contains the source dedicated SQL pool to be restored.
168+
1. List the restore points for the dedicated SQL pool using `Get-AzSqlDatabaseRestorePoint`.
169+
1. Pick the desired restore point, setting the variable `$PointInTime`.
170+
1. In the destination tenant, make sure your user has guest access with either 'Owner' or 'Contributor' permissions.
171+
1. Select the destination subscription along with the corresponding Tenant ID to which the dedicated SQL pool should be restored.
172+
1. Restore the dedicated SQL pool to the desired restore point using `Restore-AzSqlDatabase`.
173+
1. Verify that the restored dedicated SQL pool (formerly SQL DW) is online in the new tenant.
174+
175+
```powershell
176+
$SourceSubscriptionName="<YourSubscriptionName>"
177+
$SourceTenantID="<YourTenantID>" # like '00000000-0000-0000-0000-000000000000'
178+
$SourceResourceGroupName="<YourResourceGroupName>"
179+
$SourceServerName="<YourServerNameWithoutURLSuffixSeeNote>" # Without database.windows.net
180+
$SourceDatabaseName="<YourDatabaseName>"
181+
$TargetSubscriptionName="<YourTargetSubscriptionName>"
182+
$TargetTenantID="YourTargetTenantID>" # like '00000000-0000-0000-0000-000000000000'
183+
$TargetResourceGroupName="<YourTargetResourceGroupName>"
184+
$TargetServerName="<YourTargetServerNameWithoutURLSuffixSeeNote>" # Without database.windows.net
185+
$TargetDatabaseName="<YourDatabaseName>"
186+
187+
# Update Az.Sql module to the latest version (3.8.0 or above)
188+
# Update-Module -Name Az.Sql
189+
190+
Connect-AzAccount
191+
Get-AzSubscription
192+
Set-AzContext -Subscription $SourceSubscriptionName -Tenant $SourceTenantID
193+
194+
# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
195+
$PointInTime="<RestorePointCreationDate>"
196+
# Or list all restore points
197+
Get-AzSqlDatabaseRestorePoint -ResourceGroupName $SourceResourceGroupName -ServerName $SourceServerName -DatabaseName $SourceDatabaseName
198+
199+
# Get the specific database to restore
200+
$Database = Get-AzSqlDatabase -ResourceGroupName $SourceResourceGroupName -ServerName $SourceServerName -DatabaseName $SourceDatabaseName
201+
202+
# Switch context to the destination, providing both the subscription and tenant
203+
Set-AzContext -Subscription $TargetSubscriptionName -Tenant $TargetTenantID
204+
205+
# Restore database from a desired restore point of the source database to the target server in the desired subscription
206+
$RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTime $PointInTime -ResourceGroupName $TargetResourceGroupName -ServerName $TargetServerName -TargetDatabaseName $TargetDatabaseName –ResourceId $Database.ResourceID
207+
208+
# Verify the status of restored database
209+
$RestoredDatabase.status
210+
211+
```
212+
153213
## Next Steps
154214

155215
- [Restore a deleted dedicated SQL pool (formerly SQL DW)](sql-data-warehouse-restore-deleted-dw.md)

0 commit comments

Comments
 (0)