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

azureazure-devopsazure-pipelinesazure-sql-databasemsbuild

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

Best Answer

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.

Related Topic