削除されたワークスペースからの専用 SQL プールの復元

この記事では、PowerShell を使用してワークスペースを誤って破棄した後、Azure Synapse Analytics で専用 SQL プールを復元する方法について説明します。

注意

このガイダンスは、Azure Synapse ワークスペースの専用 SQL プールのみを対象としています。 スタンドアロンの専用 SQL プール (旧称 SQL DW) については、削除されたサーバーからの SQL プールの復元に関するガイダンスに従ってください。

開始する前に

注意

Azure を操作するには、Azure Az PowerShell モジュールを使用することをお勧めします。 作業を始めるには、「Azure PowerShell をインストールする」を参照してください。 Az PowerShell モジュールに移行する方法については、「AzureRM から Az への Azure PowerShell の移行」を参照してください。

破棄されたワークスペースから SQL プールを復元する

次のサンプル スクリプトでは、以下の手順を実行します。

  1. PowerShell を開きます

  2. Azure アカウントに接続します。

  3. 破棄されたワークスペースを含むサブスクリプションにコンテキストを設定します。

  4. ワークスペースが破棄された日時を特定します。 この手順では、ワークスペース SQL プールが破棄された正確な日付と時刻を取得します。

    • この手順では、ワークスペースが同じ名前のリソース グループと同じ値でまだ利用できることを想定しています。
    • そうでない場合は、同じワークスペース名、リソース グループ名、リージョン、および以前に破棄されたワークスペースと同じ値を使用して、破棄されたワークスペースを再作成します。
  5. 復旧したい SQL プールのリソース ID の文字列を構築します。 この形式では Microsoft.Sql が必要です。 これには、サーバーが破棄された日時が含まれます。

  6. 破棄されたワークスペースからデータベースを復元します。 ソース SQL プールを使用してターゲット ワークスペースに復元します。

  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
    
    # Get the exact date and time the workspace SQL pool was dropped.
    # This assumes that the workspace with the same name resource group and same values is still available.
    # If not, recreate the dropped workspace with the same workspace name, resource group name, region, 
    # and all the same values from prior dropped workspace.
    # There should only be one selection to select from.
    $paramsGetDroppedSqlPool = @{
        ResourceGroupName = $ResourceGroupName
        WorkspaceName     = $WorkspaceName
        Name              = $DatabaseName
    }
    $DroppedDateTime = Get-AzSynapseDroppedSqlPool @paramsGetDroppedSqlPool `
        | Select-Object -ExpandProperty DeletionDate
    
    # Construct a string of the resource ID of the sql pool you wish to recover.
    # The format requires 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.
    $paramsRestoreSqlPool = @{
        FromDroppedSqlPool  = $true
        DeletionDate        = $DroppedDateTime
        TargetSqlPoolName   = $TargetDatabaseName
        ResourceGroupName   = $TargetResourceGroupName
        WorkspaceName       = $TargetWorkspaceName
        ResourceId          = $SourceDatabaseID
    }
    $RestoredDatabase = Restore-AzSynapseSqlPool @paramsRestoreSqlPool
    
    # Verify the status of restored database
    $RestoredDatabase.status
    

トラブルシューティング

"An unexpected error occurred while processing the request" (要求の処理中に予期しないエラーが発生しました) というメッセージが受信された場合、元のワークスペースの有効期間が短かったため、元のデータベースに復旧ポイントがない可能性があります。 これは通常、ワークスペースの存在が 1 時間に満たない場合です。