Skip to content

Commit 06c5996

Browse files
authored
Added cross tenant restore feature Lines 209 to 282
Added cross tenant restore feature Lines 209 to 282. @WilliamDAssafMSFT, please review as we discussed.
1 parent 6f4ad9c commit 06c5996

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

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

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,81 @@ $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 PowerShell script below is similar to the above, however there are three main differences:
216+
217+
• After retrieving the SQL Pool object to be restored, the subscription and the tenant context needs to be switched to the destination (or target) tenant ID and subscription name or ID.
218+
• When performing the restore, use the Az.Sql modules instead of the Az.Synapse modules.
219+
• The below sample code has additional steps for restoring to an Azure Synapse workspace in the destination subscription. Uncomment the PowerShell commands as described in the sample.
220+
221+
Steps:
222+
223+
1. Open a PowerShell terminal.
224+
2. Update Az.Sql Module to 3.8.0 (or greater) if needed
225+
3. Connect to your Azure account and list all the subscriptions associated with your account along with its Tenant ID.
226+
4. Select the subscription that contains the SQL pool to be restored.
227+
5. List the restore points for the dedicated SQL pool.
228+
6. Pick the desired restore point using the RestorePointCreationDate.
229+
7. Create a ‘Guest’ account with either ‘Owner’ or ‘Contributor’ permissions.
230+
8. Select the destination subscription along with the corresponding Tenant ID to which the SQL pool should be restored.
231+
9. Restore the dedicated SQL pool to the desired restore point using Restore-AzSqlDatabase PowerShell cmdlet.
232+
10. Verify that the restored dedicated SQL pool (formerly SQL DW) is online.
233+
11. If the desired destination is a Synapse Workspace, uncomment the code to perform the additional restore step.
234+
a. Create a restore point for the newly created data warehouse.
235+
b. Retrieve the last restore point created by using the Select -Last 1 syntax.
236+
c. Perform the restore to the desired Azure Synapse workspace.
237+
238+
```powershell
239+
$SubscriptionName="<YourSubscriptionName>"
240+
$TenantID= ”<Your Tenant ID>”
241+
$TargetSubscriptionName= ”<YourTargetSubscriptionName>”
242+
$TargetTenantID= ”Your Target Tenant ID>”
243+
$ResourceGroupName="<YourResourceGroupName>"
244+
$WorkspaceName="<YourWorkspaceNameWithoutURLSuffixSeeNote>“ # Without sql.azuresynapse.net
245+
#$TargetResourceGroupName="<YourTargetResourceGroupName>" # uncomment to restore to a different workspace.
246+
#$TargetWorkspaceName="<YourtargetWorkspaceNameWithoutURLSuffixSeeNote>"
247+
$SQLPoolName="<YourDatabaseName>"
248+
$NewSQLPoolName="<YourDatabaseName>"
249+
250+
Connect-AzAccount
251+
Get-AzSubscription
252+
Select-AzSubscription -SubscriptionName $SubscriptionName
253+
254+
# list all restore points
255+
Get-AzSynapseSqlPoolRestorePoint -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName
256+
# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
257+
$PointInTime="<RestorePointCreationDate>"
258+
259+
# Get the specific SQL pool to restore
260+
$SQLPool = Get-AzSynapseSqlPool -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName
261+
# Transform Synapse SQL pool resource ID to SQL database ID because currently the restore command only accepts the SQL database ID format.
262+
$DatabaseID = $SQLPool.Id -replace "Microsoft.Synapse", "Microsoft.Sql" `
263+
-replace "workspaces", "servers" `
264+
-replace "sqlPools", "databases"
265+
266+
#Switch the context to the Subscription name and tenant ID to which the database would be restored to
267+
Set-AzContext -Subscription 'MySubscriptionName' -Tenant '00000000-0000-0000-0000-000000000000'
268+
269+
# Restore database from a restore point
270+
$RestoredDatabase = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $PointInTime -ResourceGroupName $SQLPool.ResourceGroupName `
271+
-WorkspaceName $SQLPool.WorkspaceName -TargetSqlPoolName $NewSQLPoolName –ResourceId $DatabaseID -PerformanceLevel DW100c
272+
273+
274+
# Use the following command to restore to a different workspace
275+
#$TargetResourceGroupName = $SQLPool.ResourceGroupName # for restoring to different workspace in same resourcegroup
276+
#$RestoredDatabase = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $PointInTime -ResourceGroupName $TargetResourceGroupName `
277+
# -WorkspaceName $TargetWorkspaceName -TargetSqlPoolName $NewSQLPoolName –ResourceId $DatabaseID -PerformanceLevel DW100c
278+
279+
# Verify the status of restored database
280+
$RestoredDatabase.status
281+
282+
```
283+
209284
## Troubleshooting
210285
A restore operation can result in a deployment failure based on a "RequestTimeout" exception.
211286

0 commit comments

Comments
 (0)