快速入門:將資料庫還原到受控執行個體Quickstart: Restore a database to a Managed Instance

在本快速入門中,您將使用 SQL Server Management Studio (SSMS),將資料庫 (Wide World Importers - Standard 備份檔案) 從 Azure Blob 儲存體還原至 Azure SQL Database 受控執行個體In this quickstart, you'll use SQL Server Management Studio (SSMS) to restore a database (the Wide World Importers - Standard backup file) from Azure Blob storage into an Azure SQL Database Managed Instance.

注意

如需使用 Azure 資料庫移轉服務 (DMS) 進行移轉的詳細資訊,請參閱使用 DMS 的受控執行個體移轉For more information on migration using the Azure Database Migration Service (DMS), see Managed Instance migration using DMS. 如需各種移轉方法的詳細資訊,請參閱將 SQL Server 執行個體移轉至 Azure SQL Database 受控執行個體For more information on various migration methods, see SQL Server instance migration to Azure SQL Database Managed Instance.

必要條件Prerequisites

此快速入門:This quickstart:

注意

如需有關使用 Azure Blob 儲存體和共用存取簽章 (SAS) 金鑰來備份和還原 SQL Server 資料庫的詳細資訊,請參閱 SQL Server 備份到 URLFor more information on backing up and restoring a SQL Server database using Azure Blob storage and a Shared Access Signature (SAS) key, see SQL Server Backup to URL.

從備份檔案還原資料庫Restore the database from a backup file

在 SSMS 中,遵循這些步驟以將 Wide World Importers 資料庫還原至您的受控執行個體。In SSMS, follow these steps to restore the Wide World Importers database to your Managed Instance. 資料庫備份檔案儲存在預先設定的 Azure Blob 儲存體帳戶中。The database backup file is stored in a pre-configured Azure Blob storage account.

  1. 開啟 SMSS 並連線到您的受控執行個體。Open SMSS and connect to your Managed Instance.

  2. 從左側功能表中,以滑鼠右鍵按一下您的受控執行個體,並選取 [新增查詢] 以開啟新的查詢視窗。From the left-hand menu, right-click your Managed Instance and select New Query to open a new query window.

  3. 執行下列 SQL 指令碼,它會使用預先設定的儲存體帳戶和 SAS 金鑰,在您的受控執行個體中建立認證Run the following SQL script, which uses a pre-configured storage account and SAS key to create a credential in your Managed Instance.

    CREATE CREDENTIAL [https://mitutorials.blob.core.windows.net/databases]
    WITH IDENTITY = 'SHARED ACCESS SIGNATURE'
    , SECRET = 'sv=2017-11-09&ss=bfqt&srt=sco&sp=rwdlacup&se=2028-09-06T02:52:55Z&st=2018-09-04T18:52:55Z&spr=https&sig=WOTiM%2FS4GVF%2FEEs9DGQR9Im0W%2BwndxW2CQ7%2B5fHd7Is%3D'
    

    建立認證

  4. 若要檢查您的認證,請執行下列指令碼,它會使用容器 URL 來取得備份檔案清單。To check your credential, run the following script, which uses a container URL to get a backup file list.

    RESTORE FILELISTONLY FROM URL =
       'https://mitutorials.blob.core.windows.net/databases/WideWorldImporters-Standard.bak'
    

    檔案清單

  5. 執行下列程式碼以還原 Wide World Importers 資料庫。Run the following script to restore the Wide World Importers database.

    RESTORE DATABASE [Wide World Importers] FROM URL =
      'https://mitutorials.blob.core.windows.net/databases/WideWorldImporters-Standard.bak'
    

    還原

  6. 執行下列程式碼來追蹤還原的狀態。Run the following script to track your restore's status.

    SELECT session_id as SPID, command, a.text AS Query, start_time, percent_complete
       , dateadd(second,estimated_completion_time/1000, getdate()) as estimated_completion_time
    FROM sys.dm_exec_requests r
    CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a
    WHERE r.command in ('BACKUP DATABASE','RESTORE DATABASE')
    
  7. 當還原完成時,請在 [物件總管] 加以檢視。When the restore completes, view it in Object Explorer.

後續步驟Next steps