Skip to main content

db bacpac to sql backup/restore

Often there is a need to run a local database in order to develop locally; sometimes this can be due to breaking changes / offline working / better end to end testing / development performance.

note

Pre-requisites: Local Sql Server and Sql Server Management Studio.

In order to achieve the above you can do the following:

  • Navigate to the desired db in Azure, perform an Export.
  • Once the export is complete, navigate to the Storage Account and download the bacpac file.
  • In SSMS, connect to your local sql instance.
  • Right Click Databases, Import Data-tier Application.
  • Click through the prompts, selecting the recently downloaded bacpac file, and setting your desired db name for import.
  • Once complete, you will have a local version of the backed up db.

Using SSMS you will be able to connect to the db using your Windows Auth, however when connecting via your application you may require using a connection string.

  • Right click on the Server in Object Explorer > Properties > Connections and ensure Allow remote connections to this server is checked under the Remote server connections section.

Right click on Security > Logins in Object Explorer, New Login. Use Sql Server Authentication and specific a Login name and password. Ensure the correct permissions are granted and consider mapping the user to a user in the newly imported db.

Once complete, test your connection by using Connect > Database Engine in the Object Explorer, use Sql Server Authentication and enter the Login name and password created in the previous step; if this connects and you are able to see the required dbs, you are free to use these credentials in your local application connection strings.