Skip to content

Commit da1cea6

Browse files
20221207 combine PRs, new instructions for dedicated SQL pool cross-tenant restore
1 parent ab73807 commit da1cea6

File tree

2 files changed

+93
-69
lines changed

2 files changed

+93
-69
lines changed

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

Lines changed: 63 additions & 44 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

@@ -210,72 +210,90 @@ $RestoredDatabase.status
210210

211211
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.
212212

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.
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.
214214

215-
The Powershell script for cross tenant restore works the in the same way as cross-subscription restore when the user is given 'GUEST' access to the destination tenant. As a best practice it is advised to also use the destination Tenant ID along with the destination subscription ID.
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.
216216

217217
Steps:
218218

219-
1. Open a PowerShell terminal.
220-
2. Update Az.Sql Module to 3.8.0 (or greater) if needed
221-
3. Connect to your Azure account and list all the subscriptions associated with your account along with its Tenant ID.
222-
4. Select the subscription that contains the SQL pool to be restored.
223-
5. List the restore points for the dedicated SQL pool.
224-
6. Pick the desired restore point using the RestorePointCreationDate.
225-
7. Create a ‘Guest’ account with either ‘Owner’ or ‘Contributor’ permissions.
226-
8. Select the destination subscription along with the corresponding Tenant ID to which the SQL pool should be restored.
227-
9. Restore the dedicated SQL pool to the desired restore point using Restore-AzSqlDatabase PowerShell cmdlet.
228-
10. Verify that the restored dedicated SQL pool (formerly SQL DW) is online.
229-
11. If the desired destination is a Synapse Workspace, uncomment the code to perform the additional restore step.
230-
a. Create a restore point for the newly created data warehouse.
231-
b. Retrieve the last restore point created by using the Select -Last 1 syntax.
232-
c. Perform the restore to the desired Azure Synapse workspace.
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+
233234

234235
```powershell
235-
$SubscriptionName="<YourSubscriptionName>"
236-
$TenantID= ”<Your Tenant ID>”
237-
$TargetSubscriptionName= ”<YourTargetSubscriptionName>”
238-
$TargetTenantID= ”Your Target Tenant ID>”
239-
$ResourceGroupName="<YourResourceGroupName>"
240-
$WorkspaceName="<YourWorkspaceNameWithoutURLSuffixSeeNote>“ # Without sql.azuresynapse.net
241-
#$TargetResourceGroupName="<YourTargetResourceGroupName>" # uncomment to restore to a different workspace.
242-
#$TargetWorkspaceName="<YourtargetWorkspaceNameWithoutURLSuffixSeeNote>"
243-
$SQLPoolName="<YourDatabaseName>"
244-
$NewSQLPoolName="<YourDatabaseName>"
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
245250
246251
Connect-AzAccount
247252
Get-AzSubscription
248-
Select-AzSubscription -SubscriptionName $SubscriptionName
253+
Select-AzSubscription -SubscriptionName $SourceSubscriptionName
254+
255+
# Set content to the source subscription and tenant
256+
Set-AzContext -Subscription $SourceSubscriptionName -Tenant $SourceTenantID
249257
250258
# list all restore points
251-
Get-AzSynapseSqlPoolRestorePoint -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName
259+
Get-AzSynapseSqlPoolRestorePoint -ResourceGroupName $SourceResourceGroupName -WorkspaceName $SourceWorkspaceName -Name $SourceSQLPoolName
252260
# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
253261
$PointInTime="<RestorePointCreationDate>"
254262
255263
# Get the specific SQL pool to restore
256-
$SQLPool = Get-AzSynapseSqlPool -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName
264+
$SQLPool = Get-AzSynapseSqlPool -ResourceGroupName $SourceResourceGroupName -WorkspaceName $SourceWorkspaceName -Name $SourceSQLPoolName
257265
# Transform Synapse SQL pool resource ID to SQL database ID because currently the restore command only accepts the SQL database ID format.
258266
$DatabaseID = $SQLPool.Id -replace "Microsoft.Synapse", "Microsoft.Sql" `
259267
-replace "workspaces", "servers" `
260268
-replace "sqlPools", "databases"
261269
262-
#Switch the context to the Subscription name and tenant ID to which the database would be restored to
263-
Set-AzContext -Subscription 'MySubscriptionName' -Tenant '00000000-0000-0000-0000-000000000000'
270+
# Switch context to the destination subscription and tenant
271+
Set-AzContext -Subscription $TargetSubscriptionName -Tenant $TargetTenantID
264272
265-
# Restore database from a restore point
266-
$RestoredDatabase = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $PointInTime -ResourceGroupName $SQLPool.ResourceGroupName `
267-
-WorkspaceName $SQLPool.WorkspaceName -TargetSqlPoolName $NewSQLPoolName –ResourceId $DatabaseID -PerformanceLevel DW100c
268-
269-
270-
# Use the following command to restore to a different workspace
271-
#$TargetResourceGroupName = $SQLPool.ResourceGroupName # for restoring to different workspace in same resourcegroup
272-
#$RestoredDatabase = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $PointInTime -ResourceGroupName $TargetResourceGroupName `
273-
# -WorkspaceName $TargetWorkspaceName -TargetSqlPoolName $NewSQLPoolName –ResourceId $DatabaseID -PerformanceLevel DW100c
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
274276
275277
# Verify the status of restored database
276278
$RestoredDatabase.status
277279
278-
```
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+
279297

280298
## Troubleshooting
281299
A restore operation can result in a deployment failure based on a "RequestTimeout" exception.
@@ -290,3 +308,4 @@ This timeout can be ignored. Review the dedicated SQL pool page in the Azure por
290308

291309
- [Create a restore point](sqlpool-create-restore-point.md)
292310
- [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)

0 commit comments

Comments
 (0)