Quickstart: Restore a database to Azure SQL Managed Instance with SSMS
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 to Azure SQL Managed Instance.
For more information on migration using Azure Database Migration Service, see SQL Managed Instance migration using Database Migration Service. For more information on various migration methods, see SQL Server migration to Azure SQL Managed Instance.
- Uses resources from the Create a managed instance quickstart.
- Requires the latest version of SSMS installed.
- Requires using SSMS to connect to SQL Managed Instance. See these quickstarts on how to connect:
- Enable a public endpoint on SQL Managed Instance - this is the recommended approach for this tutorial.
- Connect to SQL Managed Instance from an Azure VM.
- Configure a point-to-site connection to SQL Managed Instance from on-premises.
Restore from a backup file
In SQL Server Management Studio, follow these steps to restore the Wide World Importers database to SQL Managed Instance. The database backup file is stored in a pre-configured Azure Blob storage account.
Open SSMS and connect to your managed instance.
In Object Explorer, right-click your managed instance and select New Query to open a new query window.
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'
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'
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'
Run the following script to track the status of your restore.
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')
When the restore completes, view the database in Object Explorer. You can verify that database restore is completed using the sys.dm_operation_status view.
A database restore operation is asynchronous and retryable. You might get an error in SQL Server Management Studio if the connection breaks or a time-out expires. Azure SQL Database will keep trying to restore database in the background, and you can track the progress of the restore using the sys.dm_exec_requests and sys.dm_operation_status views.
In some phases of the restore process, you will see a unique identifier instead of the actual database name in the system views. Learn about
RESTORE statement behavior differences here.
- If, at step 5, a database restore is terminated with the message ID 22003, create a new backup file containing backup checksums and perform the restore again. See Enable or disable backup checksums during backup or restore.
- For troubleshooting a backup to a URL, see SQL Server Backup to URL best practices and troubleshooting.
- For an overview of app connection options, see Connect your applications to SQL Managed Instance.
- To query using your favorite tools or languages, see Quickstarts: Azure SQL Database connect and query.