Skip to content

Commit a61a770

Browse files
authored
Updated Dedicated SQL Pool code
1 parent aa0f2e8 commit a61a770

File tree

1 file changed

+25
-36
lines changed

1 file changed

+25
-36
lines changed

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

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ $RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTim
150150
$RestoredDatabase.status
151151
```
152152
## Restore an existing dedicated SQL pool (formerly SQL DW) to a different tenant through PowerShell
153-
This is similar guidance to restoring an existing dedicated SQL pool, 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 subscription 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 subscription.
153+
This is similar guidance to restoring an existing dedicated SQL pool, 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.
154154

155-
Note that the user performing the restore must have proper permissions in both the source and target subscriptions.The 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.
155+
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.
156156

157157
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.
158158

@@ -166,51 +166,40 @@ The Powershell script for cross tenant restore works the in the same way as cros
166166
8. Select the destination subscription along with the corresponding Tenant ID to which the SQL pool should be restored.
167167
9. Restore the dedicated SQL pool to the desired restore point using Restore-AzSqlDatabase PowerShell cmdlet.
168168
10. Verify that the restored dedicated SQL pool (formerly SQL DW) is online.
169-
11. If the desired destination is a Synapse Workspace, uncomment the code to perform the additional restore step.
170-
a. Create a restore point for the newly created data warehouse.
171-
b. Retrieve the last restore point created by using the Select -Last 1 syntax.
172-
c. Perform the restore to the desired Azure Synapse workspace.
169+
173170

174171
```powershell
175-
$SubscriptionName="<YourSubscriptionName>"
176-
$TenantID= ”<Your Tenant ID>”
177-
$TargetSubscriptionName= ”<YourTargetSubscriptionName>”
178-
$TargetTenantID= ”Your Target Tenant ID>”
179-
$ResourceGroupName="<YourResourceGroupName>"
180-
$WorkspaceName="<YourWorkspaceNameWithoutURLSuffixSeeNote>“ # Without sql.azuresynapse.net
181-
#$TargetResourceGroupName="<YourTargetResourceGroupName>" # uncomment to restore to a different workspace.
182-
#$TargetWorkspaceName="<YourtargetWorkspaceNameWithoutURLSuffixSeeNote>"
183-
$SQLPoolName="<YourDatabaseName>"
184-
$NewSQLPoolName="<YourDatabaseName>"
172+
$SourceSubscriptionName="<YourSubscriptionName>"
173+
$SourceTenantID="<YourTenantID>"
174+
$SourceResourceGroupName="<YourResourceGroupName>"
175+
$SourceServerName="<YourServerNameWithoutURLSuffixSeeNote>" # Without database.windows.net
176+
$SourceDatabaseName="<YourDatabaseName>"
177+
$TargetSubscriptionName="<YourTargetSubscriptionName>"
178+
$TargetTenantID="YourTargetTenantID>"
179+
$TargetResourceGroupName="<YourTargetResourceGroupName>"
180+
$TargetServerName="<YourTargetServerNameWithoutURLSuffixSeeNote>" # Without database.windows.net
181+
$TargetDatabaseName="<YourDatabaseName>"
182+
183+
# Update Az.Sql module to the latest version (3.8.0 or above)
184+
# Update-Module -Name Az.Sql -RequiredVersion 3.8.0
185185
186186
Connect-AzAccount
187187
Get-AzSubscription
188-
Select-AzSubscription -SubscriptionName $SubscriptionName
188+
Select-AzSubscription -SubscriptionName $SourceSubscriptionName
189189
190-
# list all restore points
191-
Get-AzSynapseSqlPoolRestorePoint -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName
192190
# Pick desired restore point using RestorePointCreationDate "xx/xx/xxxx xx:xx:xx xx"
193191
$PointInTime="<RestorePointCreationDate>"
192+
# Or list all restore points
193+
Get-AzSqlDatabaseRestorePoint -ResourceGroupName $SourceResourceGroupName -ServerName $SourceServerName -DatabaseName $SourceDatabaseName
194194
195-
# Get the specific SQL pool to restore
196-
$SQLPool = Get-AzSynapseSqlPool -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SQLPoolName
197-
# Transform Synapse SQL pool resource ID to SQL database ID because currently the restore command only accepts the SQL database ID format.
198-
$DatabaseID = $SQLPool.Id -replace "Microsoft.Synapse", "Microsoft.Sql" `
199-
-replace "workspaces", "servers" `
200-
-replace "sqlPools", "databases"
201-
202-
#Switch the context to the Subscription name and tenant ID to which the database would be restored to
203-
Set-AzContext -Subscription 'MySubscriptionName' -Tenant '00000000-0000-0000-0000-000000000000'
204-
205-
# Restore database from a restore point
206-
$RestoredDatabase = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $PointInTime -ResourceGroupName $SQLPool.ResourceGroupName `
207-
-WorkspaceName $SQLPool.WorkspaceName -TargetSqlPoolName $NewSQLPoolName –ResourceId $DatabaseID -PerformanceLevel DW100c
195+
# Get the specific database to restore
196+
$Database = Get-AzSqlDatabase -ResourceGroupName $SourceResourceGroupName -ServerName $SourceServerName -DatabaseName $SourceDatabaseName
208197
198+
# Switch context to the destination subscription and Tenant
199+
Select-AzSubscription -SubscriptionName $TargetSubscriptionName -Tenant $TargetTenantID
209200
210-
# Use the following command to restore to a different workspace
211-
#$TargetResourceGroupName = $SQLPool.ResourceGroupName # for restoring to different workspace in same resourcegroup
212-
#$RestoredDatabase = Restore-AzSynapseSqlPool –FromRestorePoint -RestorePoint $PointInTime -ResourceGroupName $TargetResourceGroupName `
213-
# -WorkspaceName $TargetWorkspaceName -TargetSqlPoolName $NewSQLPoolName –ResourceId $DatabaseID -PerformanceLevel DW100c
201+
# Restore database from a desired restore point of the source database to the target server in the desired subscription
202+
$RestoredDatabase = Restore-AzSqlDatabase –FromPointInTimeBackup –PointInTime $PointInTime -ResourceGroupName $TargetResourceGroupName -ServerName $TargetServerName -TargetDatabaseName $TargetDatabaseName –ResourceId $Database.ResourceID
214203
215204
# Verify the status of restored database
216205
$RestoredDatabase.status

0 commit comments

Comments
 (0)