Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 551
JL Dajoyag Avatar asked Apr 25 '16 10:04

JL Dajoyag


3 Answers

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.

like image 104
Kevin Cunnane Avatar answered Nov 15 '22 03:11

Kevin Cunnane


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.

like image 42
fiat Avatar answered Nov 15 '22 02:11

fiat


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

like image 31
JohnnyFun Avatar answered Nov 15 '22 03:11

JohnnyFun