Thursday, April 5, 2018

How to Import database from SQL Azure to local environment

One of the most frequent thing that developers always wanted to have a copy of the development database in local. In this blog i will pen down the steps on how to export and import a database from SQL azure instance to local machine and restore it on SQL server.

Prerequisites:

You will need an Azure account and get the credentials  from Azure web portal. 

Step 1:


Get the backup from the azure instance as follows,  Select the database → Right click → Tasks →  Export Data Tier Application.


Step 2:
Give a specific name for the backup file and save it in your desired location as follows,
Step 3: That's it you have taken a backup of the database from sql instance to your local. Lets restore it to the local. Copy the backed up database to your C drive. Now open the
PowerShell with administrator rights and navigate to C drive


Step 4: Lets download the powershell script to remove the master keyRemoveMasterKey.ps1have the script on the same drive in this case its C.

Step 5 : Run the script as follows,
 .\RemoveMasterKey.ps1 -bacpacPath "C:\identity.bacpac"
That's it, now you can restore it on MSSQL 2017 in your local environment.
Step 6: Connect to your local server, and click Databases → Import-Data-Tier-Application
Step 7 : Give a name for your database to restore. 



Now you will see everything in green!


That's it folks, now you should be easily able to restore your development database in your local environment.


1 comment:

Kaashvi mohan said...
This comment has been removed by a blog administrator.