SSDT failing to publish: "Unable to connect to master or target server"
Asked Answered
D

10

13

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?

Decreasing answered 13/10, 2017 at 18:15 Comment(2)
it is not recommended to specify every IP in the firewall ruleRuffina
@VenkataramanR Obviously. I was running that out as a possible cause.Decreasing
S
18

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.

Sleety answered 13/10, 2017 at 18:39 Comment(1)
In the document that Alberto points to above it also mentions that it could be the firewall settings on the Azure ServerVallecula
O
3
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.

Orvalorvan answered 17/5, 2018 at 9:33 Comment(0)
N
1

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://learn.microsoft.com/en-us/azure/sql-database/sql-database-cloud-migrate.

Nuris answered 9/2, 2018 at 7:6 Comment(2)
Yup, this did it for me as well. Thanks a lot!Stringer
@Nuris How did you solved your issue? would you please add the solution hereTeofilateosinte
C
1

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
Chantell answered 25/5, 2018 at 22:29 Comment(0)
S
1

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

Shrunk answered 16/12, 2018 at 20:33 Comment(0)
V
0

* 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

Vitek answered 20/6, 2018 at 2:17 Comment(0)
H
0

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. ;)

Highup answered 13/12, 2018 at 9:50 Comment(0)
L
0

Most of the sources recommend to set COMPATIBILITY_LEVEL = 130; and, usually, it solves the issue. Unfortunately, this did not help me.

In my case, I had to downgrade SQL Server 2017 on my machine to SQL Server 2016 Developer Edition.

Larentia answered 7/9, 2022 at 10:37 Comment(0)
S
0

I ended up having to install DacFramework.msi on the SQL server that my azure runner agent was installed to get past this error. My server is a VM running in our network. not running in azure...

the description on the msi says: 'This installer database contains the logic and data required to install Microsoft SQL Server Data-Tier Application Framework (x64).'

Sileas answered 6/10, 2022 at 18:44 Comment(0)
R
-2

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.

Ruffina answered 13/10, 2017 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.