Skip to content

Commit ab73807

Browse files
Merge branch 'patch-1' of https://github.com/ajagadish-24/azure-docs-pr into 20221217-restore-cross-tenant-ambika
2 parents a2a681e + 242c068 commit ab73807

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,77 @@ $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 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.
216+
217+
Steps:
218+
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.
233+
234+
```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>"
245+
246+
Connect-AzAccount
247+
Get-AzSubscription
248+
Select-AzSubscription -SubscriptionName $SubscriptionName
249+
250+
# list all restore points
251+
Get-AzSynapseSqlPoolRestorePoint -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName
252+
# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
253+
$PointInTime="<RestorePointCreationDate>"
254+
255+
# Get the specific SQL pool to restore
256+
$SQLPool = Get-AzSynapseSqlPool -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName
257+
# Transform Synapse SQL pool resource ID to SQL database ID because currently the restore command only accepts the SQL database ID format.
258+
$DatabaseID = $SQLPool.Id -replace "Microsoft.Synapse", "Microsoft.Sql" `
259+
-replace "workspaces", "servers" `
260+
-replace "sqlPools", "databases"
261+
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'
264+
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
274+
275+
# Verify the status of restored database
276+
$RestoredDatabase.status
277+
278+
```
279+
209280
## Troubleshooting
210281
A restore operation can result in a deployment failure based on a "RequestTimeout" exception.
211282

0 commit comments

Comments
 (0)