Skip to content

Commit 98b7729

Browse files
authored
Merge pull request #282055 from WilliamDAssafMSFT/20240729-restore-sql-pool-from-deleted-workspace.md
20240729 restore sql pool from deleted workspace.md
2 parents 77a5bf6 + e3340da commit 98b7729

File tree

1 file changed

+46
-25
lines changed

1 file changed

+46
-25
lines changed

articles/synapse-analytics/backuprestore/restore-sql-pool-from-deleted-workspace.md

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
---
22
title: Restore a dedicated SQL pool from a dropped workspace
33
description: How-to guide for restoring a dedicated SQL pool from a dropped workspace.
4-
author: realAngryAnalytics
5-
ms.author: stevehow
6-
ms.reviewer: wiassaf
7-
ms.date: 01/23/2024
4+
author: WilliamDAssafMSFT
5+
ms.author: wiassaf
6+
ms.reviewer: stevehow, ajagadish
7+
ms.date: 07/29/2024
88
ms.service: synapse-analytics
99
ms.subservice: sql
1010
ms.topic: how-to
1111
---
12-
1312
# Restore a dedicated SQL pool from a deleted workspace
1413

1514
In this article, you learn how to restore a dedicated SQL pool in Azure Synapse Analytics after an accidental drop of a workspace using PowerShell.
@@ -23,49 +22,71 @@ In this article, you learn how to restore a dedicated SQL pool in Azure Synapse
2322

2423
## Restore the SQL pool from the dropped workspace
2524

25+
The following sample script accomplishes these steps:
26+
2627
1. Open PowerShell
2728

2829
1. Connect to your Azure account.
2930

3031
1. Set the context to the subscription that contains the workspace that was dropped.
3132

32-
1. Specify the approximate datetime the workspace was dropped.
33-
34-
1. Construct the resource ID for the database you wish to recover from the dropped workspace.
33+
1. Determine the datetime the workspace was dropped. This step retrieves the exact date and time the workspace SQL pool was dropped.
34+
- This step assumes that the workspace with the same name resource group and same values is still available.
35+
- If not, recreate the dropped workspace with the same workspace name, resource group name, region, and all the same values from prior dropped workspace.
36+
37+
1. Construct a string the resource ID of the sql pool you wish to recover. The format requires `Microsoft.Sql`. This includes the date and time when the server was dropped.
3538

36-
1. Restore the database from the dropped workspace
39+
1. Restore the database from the dropped workspace. Restore to the target workspace with the source SQL pool.
3740

3841
1. Verify the status of the recovered database as 'online'.
3942

40-
4143
```powershell
42-
$SubscriptionID="<YourSubscriptionID>"
43-
$ResourceGroupName="<YourResourceGroupName>"
44-
$WorkspaceName="<YourWorkspaceNameWithoutURLSuffixSeeNote>" # Without sql.azuresynapse.net
45-
$DatabaseName="<YourDatabaseName>"
46-
$TargetResourceGroupName="<YourTargetResourceGroupName>"
47-
$TargetWorkspaceName="<YourtargetServerNameWithoutURLSuffixSeeNote>"
48-
$TargetDatabaseName="<YourDatabaseName>"
44+
$SubscriptionID = "<YourSubscriptionID>"
45+
$ResourceGroupName = "<YourResourceGroupName>"
46+
$WorkspaceName = "<YourWorkspaceNameWithoutURLSuffixSeeNote>" # Without sql.azuresynapse.net
47+
$DatabaseName = "<YourDatabaseName>"
48+
$TargetResourceGroupName = "<YourTargetResourceGroupName>"
49+
$TargetWorkspaceName = "<YourtargetServerNameWithoutURLSuffixSeeNote>"
50+
$TargetDatabaseName = "<YourDatabaseName>"
4951
5052
Connect-AzAccount
5153
Set-AzContext -SubscriptionID $SubscriptionID
5254
53-
# Define the approximate point in time the workspace was dropped as DroppedDateTime "yyyy-MM-ddThh:mm:ssZ" (ex. 2022-01-01T16:15:00Z)
54-
$PointInTime="<DroppedDateTime>"
55-
$DroppedDateTime = Get-Date -Date $PointInTime
56-
57-
58-
# construct the resource ID of the sql pool you wish to recover. The format required Microsoft.Sql. This includes the approximate date time the server was dropped.
59-
$SourceDatabaseID = "/subscriptions/"+$SubscriptionID+"/resourceGroups/"+$ResourceGroupName+"/providers/Microsoft.Sql/servers/"+$WorkspaceName+"/databases/"+$DatabaseName
55+
# Get the exact date and time the workspace SQL pool was dropped.
56+
# This assumes that the workspace with the same name resource group and same values is still available.
57+
# If not, recreate the dropped workspace with the same workspace name, resource group name, region,
58+
# and all the same values from prior dropped workspace.
59+
# There should only be one selection to select from.
60+
$paramsGetDroppedSqlPool = @{
61+
ResourceGroupName = $ResourceGroupName
62+
WorkspaceName = $WorkspaceName
63+
Name = $DatabaseName
64+
}
65+
$DroppedDateTime = Get-AzSynapseDroppedSqlPool @paramsGetDroppedSqlPool `
66+
| Select-Object -ExpandProperty DeletionDate
6067
68+
# Construct a string of the resource ID of the sql pool you wish to recover.
69+
# The format requires Microsoft.Sql. This includes the approximate date time the server was dropped.
70+
$SourceDatabaseID = "/subscriptions/$SubscriptionID/resourceGroups/$ResourceGroupName/providers/" `
71+
+ "Microsoft.Sql/servers/$WorkspaceName/databases/$DatabaseName"
72+
6173
# Restore to the target workspace with the source SQL pool.
62-
$RestoredDatabase = Restore-AzSynapseSqlPool -FromDroppedSqlPool -DeletionDate $DroppedDateTime -TargetSqlPoolName $TargetDatabaseName -ResourceGroupName $TargetResourceGroupName -WorkspaceName $TargetWorkspaceName -ResourceId $SourceDatabaseID
74+
$paramsRestoreSqlPool = @{
75+
FromDroppedSqlPool = $true
76+
DeletionDate = $DroppedDateTime
77+
TargetSqlPoolName = $TargetDatabaseName
78+
ResourceGroupName = $TargetResourceGroupName
79+
WorkspaceName = $TargetWorkspaceName
80+
ResourceId = $SourceDatabaseID
81+
}
82+
$RestoredDatabase = Restore-AzSynapseSqlPool @paramsRestoreSqlPool
6383
6484
# Verify the status of restored database
6585
$RestoredDatabase.status
6686
```
6787
6888
## <a id="troubleshooting"></a> Troubleshoot
89+
6990
If "An unexpected error occurred while processing the request." message is received, the original database might not have any recovery points available due to the original workspace being short lived. Typically this is when the workspace existed for less than one hour.
7091
7192
## Related content

0 commit comments

Comments
 (0)