Share via


從已刪除的工作區還原專用 SQL 集區

在本文中,您會瞭解如何在使用 PowerShell 意外卸除工作區之後,在 Azure Synapse Analytics 中還原專用 SQL 集區。

注意

本指南僅適用於 Azure Synapse 工作區中的專用 SQL 集區。 若是獨立的專用 SQL 集區 (先前稱為 SQL DW),請遵循從已刪除的伺服器還原 sql 集區指南。

開始之前

注意

建議您使用 Azure Az PowerShell 模組來與 Azure 互動。 請參閱安裝 Azure PowerShell 以開始使用。 若要了解如何移轉至 Az PowerShell 模組,請參閱將 Azure PowerShell 從 AzureRM 移轉至 Az

從卸除的工作區還原 SQL 集區

  1. 開啟 PowerShell

  2. 連線至您的 Azure 帳戶。

  3. 將內容設定為含有已卸除工作區的訂用帳戶。

  4. 指定卸除工作區的大約日期時間。

  5. 建構您想要從已卸除工作區復原的資料庫資源識別碼。

  6. 從已卸除的工作區還原資料庫

  7. 確認已復原資料庫的狀態為「連線」。

    $SubscriptionID="<YourSubscriptionID>"
    $ResourceGroupName="<YourResourceGroupName>"
    $WorkspaceName="<YourWorkspaceNameWithoutURLSuffixSeeNote>"  # Without sql.azuresynapse.net
    $DatabaseName="<YourDatabaseName>"
    $TargetResourceGroupName="<YourTargetResourceGroupName>" 
    $TargetWorkspaceName="<YourtargetServerNameWithoutURLSuffixSeeNote>"  
    $TargetDatabaseName="<YourDatabaseName>"
    
    Connect-AzAccount
    Set-AzContext -SubscriptionID $SubscriptionID
    
    # Define the approximate point in time the workspace was dropped as DroppedDateTime "yyyy-MM-ddThh:mm:ssZ" (ex. 2022-01-01T16:15:00Z)
    $PointInTime="<DroppedDateTime>" 
    $DroppedDateTime = Get-Date -Date $PointInTime 
    
    
    # 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.
    $SourceDatabaseID = "/subscriptions/"+$SubscriptionID+"/resourceGroups/"+$ResourceGroupName+"/providers/Microsoft.Sql/servers/"+$WorkspaceName+"/databases/"+$DatabaseName
    
    # Restore to the target workspace with the source SQL pool.
    $RestoredDatabase = Restore-AzSynapseSqlPool -FromDroppedSqlPool -DeletionDate $DroppedDateTime -TargetSqlPoolName $TargetDatabaseName -ResourceGroupName $TargetResourceGroupName -WorkspaceName $TargetWorkspaceName -ResourceId $SourceDatabaseID
    
    # Verify the status of restored database
    $RestoredDatabase.status
    

疑難排解

如果收到「處理要求時發生未預期的錯誤。」訊息,原始資料庫可能因為原始工作區的存留期過短而沒有可用的恢復點。 一般而言,當工作區存在少於一小時時。