다음을 통해 공유


삭제된 작업 영역에서 전용 SQL 풀 복원

이 문서에서는 PowerShell을 사용하여 작업 영역을 실수로 삭제한 후 Azure Synapse Analytics에서 전용 SQL 풀을 복원하는 방법을 알아봅니다.

참고 항목

이 지침은 Azure Synapse 작업 영역의 전용 SQL 풀에만 적용됩니다. 독립 실행형 전용 SQL 풀(이전의 SQL DW)의 경우 삭제된 서버에서 SQL 풀 복원 지침을 따르세요.

시작하기 전에

참고 항목

Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.

삭제된 작업 영역에서 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
    

문제 해결

“요청을 처리하는 동안 예기치 않은 오류가 발생했습니다.” 메시지가 수신되면 원래 작업 영역의 수명이 짧아서 원래 데이터베이스에 사용 가능한 복구 지점이 없는 것일 수 있습니다. 일반적으로 작업 영역이 1시간 미만인 경우입니다.