SSDT failing to publish: “Unable to connect to master or target server”

时光总嘲笑我的痴心妄想 提交于 2019-12-01 02:02:07

问题


I'm attempting to use SSDT to publish to a SQL Server database in Azure. When I do so, I am seeing the following error:

Unable to connect to master or target server 'DATABASE_NAME'. You must have a user with the same password in master or target server 'DATABASE_NAME'.

Ignoring the fact that it's listing a database name as the server name in the error, I'm not sure how to resolve it. When I specify the target database, I can successfully Test Connection. I can also connect using the same creds to the database through SSMS.

After researching the error, it seems like it is often that the firewall for the database in Azure does not include the IP address of the machine you're publishing from. It not only contains my IP, but I added another firewall rule to allow every IP (0.0.0.0-255.255.255.255) to eliminate the firewall as a potential cause of the problem.

Any ideas?


回答1:


This is a known issue. This happens due to the new compatibility level 140 for newly created SQL Azure databases. The issue has been documented here and updating SSDT from here to the latest version may solve the issue.

Alternatively, you can change the compatibility level of your database to 130.

ALTER DATABASE database_name   
SET COMPATIBILITY_LEVEL =  130;

Hope this helps.




回答2:


Initializing deployment (Start)
Initializing deployment (Failed)
*** Could not deploy package.
Unable to connect to master or target server 'DbName'. You must have a user with the same password in master or target server 'DbName'.

Issue occurred while deploying build through VisualStudio-2015 and it support to publish database on the database servers whose version up to only 2016.

Solution: For SQL server 2017 we need to Publish Database with Visual Studia 2017 only. Need to upgrade SSDT.




回答3:


Faced same issue when trying to deploy a DB from local SQL Server to Azure SQL DB via SSMS.

Tried to alter source DB's compatibility level to 130, still got same error.

Tried to add same user logins to master DB, no help.

Eventually, started looking for other approaches. Succeeded by using Data Migration Assistant, as instructed in https://docs.microsoft.com/en-us/azure/sql-database/sql-database-cloud-migrate.




回答4:


My situation was slightly different in that I had exported an Azure database (with compat level 140) from SQL Azure and then tried to import it into a local SQL Server 2017 installation - using the latest SSMS 2017 that I just installed yesterday - and still got this message.

Turned out that although I did have latest SSMS installed, I was actually opening SSMS 2016 by mistake! So be sure to select and pin the correct version to avoid it happening again. Just typing 'SSMS' into the Windows Start menu may not show both.

So if you use SSMS to import you only need the latest version, and no separate tools.


Footnote: Even after opening the correct SSMS version I got another error - something about contained databases.

An Azure database is a 'contained' database (or at least mine was) - meaning that its user logins are embedded in the database. This isn't enabled by default apparently in standard SQL Server 2017.

After running this in the local SQL in master I was able to import it successfully.

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



回答5:


* to publish to a SQL Server database in Azure*, you can use "Data Migration Assistant" (DMA).

I just tried it and it works smoothly without any issues (firewall and compatibility level)

please refer to this link SQL Server database migration to Azure SQL Database

for step by step: 10. How to migrate the SQL database to Azure with the Azure Database Migration Service




回答6:


I got the same error while trying to update a local SQL Server database from Visual Studio database project (i.e. not i Azure). Turns out the problem was I was running SSDT for Visual Studio 2017 while using Visual Studio 2015. Visual Studio discovered an updated version of SSDT (just happened to see it in notifications!), pointing to the right Visual Studio version. Now it works!

My setup: BizTalk Server 2016 forces me to use Visual Studio 2015. My local database is on SQL Server 2017. Using SSDT for Visual Studio 2015 works for updating databases in SQL Server 2017. Just so you know. ;)




回答7:


When this happened to me it was due to the version of tools I was using. I thought it strange that the most recent SqlPackage.exe I found in C:\Program Files (x86)\Microsoft SQL Server didn't work and publishing from visual studio did, so I found the most recent under the visual studio directories:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150\SqlPackage.exe




回答8:


Try to connect to the SQL Azure database using Sql Server Management Studio and the ip getting listed in the management studio is the right ip address. Try to add to the SQL Azure firewall rules. The ip address listed in the firewall page of Sql Azure portal is not accurate.



来源:https://stackoverflow.com/questions/46735814/ssdt-failing-to-publish-unable-to-connect-to-master-or-target-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!