简体   繁体   中英

Visual Studio Team Services Build Failed - Database Project to Azure SQL

I have a build in Team Services (was Visual Studio Online), with one MSBuild step that is configured to build and deploy a DB project, using a publish profile. I can't seem to succeed in authenticating it. When I queued the Team Services build definition, I am able to build the DB Project and produce the .dacpac. However, come publish time and this error comes:

C:\\a\\1\\s\\Source\\ShopDatabase\\bin\\Output\\MyDatabase.publish.sql(0,0): Error Deploy72002: Unable to connect to master or target server 'mydb'. You must have a user with the same password in master or target server 'mydb'.

We're certain the user exists in the mydb and the master db in Azure.

Target: Azure SQL Database

DB project Target Platform: Microsoft Azure SQL Database

When I run the publish profile directly from Visual Studio, it works. But in Team Services build definition, it doesn't. I tried these as MSbuild arguments:

/t:Build;Publish /p:SqlPublishProfilePath="myproject.Dev.publish.xml" /p:Password="mypassword"

and this:

/t:Build;Publish /p:SqlPublishProfilePath="myproject.Dev.publish.xml" /p:TargetConnectionString="Data Source=myproject.database.windows.net;Persist Security Info=True;User ID=myuser;Password=mypassword;" /p:VisualStudioVersion=14.0 /p:Username="myuser" /p:Password="mypassword"

and this:

/t:Build;Publish /p:SqlPublishProfilePath="myproject.Dev.publish.xml" /p:TargetConnectionString="Data Source=myproject.database.windows.net;Persist Security Info=True;User ID=myuser;Password=mypassword;" /p:VisualStudioVersion=14.0 /p:TargetUserName="myuser" /p:TargetPassword="mypassword"

But won't work. Please help me T_T been searching the net for 6 hours already

This is a poor error message that likely disguises the real issue: you need to open up your firewall for deployment to Azure SQL DB. It's working from Visual Studio because you have your IP range enabled. The steps in this guide to building & deploying from VSO , specifically the post on deploying from VSO here, should help. it specifically covers how to open up the firewall as part of deployment.

An obvious answer (sometimes in hindsight!) but for future googlers the error You must have a user with the same password in master or target server

also happens if you are pointing your deploy to an instance that doesn't exist. ie: Server was not found.

Fwiw, was generating a script from visual studio. Running as admin made it stop being a douche about this. What a waste of my life just now...

We recently had this issue and we resolved it by removing the @server-name from the end of the Server Admin Login value in the SQL DB Details section of the SQL Deploy VSTS Task. Some guides online say you need this but it appears something changed recently and it is no longer required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM