Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure SQL Server BACPAC import failed

whenever i try to import BACPAC on local sql server I am getting below error message:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Could not import package.
Warning SQL0: The source contains users that rely on an external authentication provider that is not supported by the target. These users will be treated as users without logins.
Warning SQL72012: The object [DB_NAME_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Warning SQL72012: The object [DB_NAME_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Error SQL72014: .Net SqlClient Data Provider: Msg 33161, Level 15, State 1, Line 1 Database master keys without password are not supported in this version of SQL Server.
Error SQL72045: Script execution error.  The executed script:
CREATE MASTER KEY;


 (Microsoft.SqlServer.Dac)

------------------------------
BUTTONS:

OK
------------------------------

All the previously reported issues on SO are not same as this one. Does anyone faced the same issue before?

like image 550
Deepak Kumar Avatar asked Nov 10 '17 00:11

Deepak Kumar


People also ask

How do I import data from Bacpac to Azure SQL server?

To import from a BACPAC file into a new single database using the Azure portal, open the appropriate server page and then, on the toolbar, select Import database. Select the storage account and the container for the BACPAC file and then select the BACPAC file from which to import.

How do I import a Bacpac file into Azure Data Studio?

bacpac file. To do this in Azure Data Studio, right-click on your connection and select the Data-tier application wizard option and then select the Export the schema and data from a database to the logical . bacpac file format option. The wizard will detect the connection server name and the source database.

Can we import Bacpac file into SQL Server?

Steps to Import/Restore BACPAC file. Open SQL Server management studio, connect to SQL instances where you want to restore database and right click on Database. Then you will get option as shown in below picture. Click on Import Data-tier Application.


Video Answer


2 Answers

Try running this against your master database (right click on the server name in SSMS -> New Query)

sp_configure 'contained database authentication', 1;
GO 
RECONFIGURE;
GO

After this, you can go through the import bacpac wizard again and the issue should be resolved.

like image 143
Sadra Abedinzadeh Avatar answered Oct 18 '22 20:10

Sadra Abedinzadeh


Eventually I was able to resolve this issue by following option 2 suggested here

In nutshell,

  1. Save the utility RemoveMasterKeyFrombacpac from here
  2. Run the command .\RemoveMasterKey.ps1 -bacpacPath "C:\BacPacs\fileName.bacpac"

Once above command finishes we get the -patched bacpac which imported seamlessly.

Update

With new MS SQL Server 2016 (13.0.1745.2) and SSMS v17.6 this is not an issue anymore.

like image 27
Deepak Kumar Avatar answered Oct 18 '22 20:10

Deepak Kumar