azure-devopssql-server-data-toolsdacpacsql-server-2019ssdt-2019

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


I am going to automate the database deployment through SSDT-DACPAC by using Visual Studio 2019, DATABASE from where changes will deploy is SQL SERVER 2019, and for deployment medium I am using Azure pipeline and task 'SQL Server database deploy' when deployment starts it throw an error

  *** Could not deploy package.
      Unable to connect to master or target server 'DB_NAME'. You must have a user with the same 
      password in master or target server 'DB_NAME'.

Although I have double verifies the database's user and the password, same password connects me to ssms

Please find log

2020-07-22T06:51:57.3001061Z ##[debug]Evaluating condition for step: 'Deploy using : dacpac'
2020-07-22T06:51:57.3004812Z ##[debug]Evaluating: succeeded()
2020-07-22T06:51:57.3005875Z ##[debug]Evaluating succeeded:
2020-07-22T06:51:57.3008135Z ##[debug]=> True
2020-07-22T06:51:57.3009350Z ##[debug]Result: True
2020-07-22T06:51:57.3010674Z ##[section]Starting: Deploy using : dacpac
2020-07-22T06:51:57.3715291Z ==============================================================================
2020-07-22T06:51:57.3716242Z Task         : SQL Server database deploy
2020-07-22T06:51:57.3717049Z Description  : Deploy a SQL Server database using DACPAC or SQL scripts
2020-07-22T06:51:57.3717746Z Version      : 0.3.23
2020-07-22T06:51:57.3718317Z Author       : Microsoft Corporation
2020-07-22T06:51:57.3719290Z Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/sql-dacpac-deployment-on-machine-group
2020-07-22T06:51:57.3720387Z ==============================================================================
2020-07-22T06:51:59.4759713Z ##[debug]VstsTaskSdk 0.8.2 commit 
2020-07-22T06:51:59.7919661Z ##[debug]Entering C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\Main.ps1.
2020-07-22T06:51:59.8208606Z ##[debug]Loading resource strings from: C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\Task.json
2020-07-22T06:51:59.8849723Z ##[debug]Loaded 6 strings.
2020-07-22T06:51:59.8951721Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-07-22T06:51:59.9013310Z ##[debug]Loading resource strings from: C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\Strings\resources.resjson\en-US\resources.resjson
2020-07-22T06:51:59.9474383Z ##[debug]Loaded 6 strings.
2020-07-22T06:52:00.0039076Z ##[debug]INPUT_TASKTYPE: 'dacpac'
2020-07-22T06:52:00.0080924Z ##[debug]INPUT_DACPACFILE: 'C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac'
2020-07-22T06:52:00.0120089Z ##[debug]INPUT_SQLFILE (empty)
2020-07-22T06:52:00.0212373Z ##[debug]INPUT_EXECUTEINTRANSACTION: 'false'
2020-07-22T06:52:00.0264618Z ##[debug] Converted to bool: False
2020-07-22T06:52:00.0307892Z ##[debug]INPUT_EXCLUSIVELOCK: 'false'
2020-07-22T06:52:00.0340171Z ##[debug] Converted to bool: False
2020-07-22T06:52:00.0382331Z ##[debug]INPUT_APPLOCKNAME (empty)
2020-07-22T06:52:00.0424011Z ##[debug]INPUT_INLINESQL (empty)
2020-07-22T06:52:00.0464722Z ##[debug]INPUT_TARGETMETHOD: 'server'
2020-07-22T06:52:00.0505622Z ##[debug]INPUT_SERVERNAME: 'dbserver3\SQL2019'
2020-07-22T06:52:00.0545057Z ##[debug]INPUT_DATABASENAME: 'RIN.ActionDB_QA'
2020-07-22T06:52:00.0586508Z ##[debug]INPUT_AUTHSCHEME: 'sqlServerAuthentication'
2020-07-22T06:52:00.0632381Z ##[debug]INPUT_SQLUSERNAME: 'rin'
2020-07-22T06:52:00.0681228Z ##[debug]INPUT_SQLPASSWORD: 'password'
2020-07-22T06:52:00.0735301Z ##[debug]INPUT_CONNECTIONSTRING (empty)
2020-07-22T06:52:00.0772570Z ##[debug]INPUT_PUBLISHPROFILE (empty)
2020-07-22T06:52:00.0817000Z ##[debug]INPUT_ADDITIONALARGUMENTS (empty)
2020-07-22T06:52:00.0882965Z ##[debug]INPUT_ADDITIONALARGUMENTSSQL (empty)
2020-07-22T06:52:00.0931191Z ##[debug]Loading module from path 'C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\ps_modules\TaskModuleSqlUtility\TaskModuleSqlUtility.psd1'.
2020-07-22T06:52:00.1050744Z ##[debug]Loading module from path 'C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\ps_modules\TaskModuleSqlUtility\TaskModuleSqlUtility.psm1'.
2020-07-22T06:52:00.1326840Z ##[debug]NonInteractive: False
2020-07-22T06:52:00.1648048Z ##[debug]Exporting function 'Invoke-DacpacDeployment'.
2020-07-22T06:52:00.1675075Z ##[debug]Exporting function 'Invoke-SqlQueryDeployment'.
2020-07-22T06:52:00.1701383Z ##[debug]Adding exceptions types.
2020-07-22T06:52:00.3872234Z ##[debug]Importing function 'Invoke-DacpacDeployment'.
2020-07-22T06:52:00.3901455Z ##[debug]Importing function 'Invoke-SqlQueryDeployment'.
2020-07-22T06:52:00.4862535Z ##[debug]Processed: ##vso[telemetry.publish area=SqlDacpacDeploymentOnMachineGroup;feature=SqlDacpacDeploymentOnMachineGroup]{"serverName": "f63420c3593aba48d436b02f3f6972d442f242a4e4219d64244779988f9d0d65","databaseName": "c50699da6b72abf28b7d2c4f0fda79467ec5e64667447691e616c357eae8be88"}
2020-07-22T06:52:00.8502242Z ##[debug]Finding files with pattern C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac
2020-07-22T06:52:00.8790446Z ##[debug]Entering Find-VstsFiles.
2020-07-22T06:52:00.9038975Z ##[debug] LegacyPattern: 'C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac'
2020-07-22T06:52:01.0124279Z ##[debug]Entering Get-MatchingItems.
2020-07-22T06:52:01.0215255Z ##[debug] IncludePatterns: 'C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac'
2020-07-22T06:52:01.0319618Z ##[debug] ExcludePatterns: ''
2020-07-22T06:52:01.0408540Z ##[debug] IncludeFiles: 'True'
2020-07-22T06:52:01.0446810Z ##[debug] IncludeDirectories: 'False'
2020-07-22T06:52:01.0484071Z ##[debug] Force: 'False'
2020-07-22T06:52:01.3472741Z ##[debug]Path: C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac
2020-07-22T06:52:01.3551260Z ##[debug]Leaving Get-MatchingItems.
2020-07-22T06:52:01.3583140Z ##[debug]Total found: 1
2020-07-22T06:52:01.3618825Z ##[debug]Leaving Find-VstsFiles.
2020-07-22T06:52:01.3659339Z ##[debug]Matched files = C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac
2020-07-22T06:52:01.3742957Z ##[debug]Entering script SqlPackageOnTargetMachines.ps1
2020-07-22T06:52:01.4711292Z ##[debug]Sql Versions installed on machine DBSERVER3 as read from registry: 150 140 130 120 110 100 90
2020-07-22T06:52:01.5560135Z ##[debug]Sql Version Specific Root Dir for version 150 as read from registry: C:\Program Files\Microsoft SQL Server\150\
2020-07-22T06:52:01.5665581Z ##[debug]Sql Version Specific Root Dir for version 150 as read from registry: C:\Program Files (x86)\Microsoft SQL Server\150\
2020-07-22T06:52:01.5752688Z ##[debug]Sql Version Specific Root Dir for version 140 as read from registry: C:\Program Files (x86)\Microsoft SQL Server\140\
2020-07-22T06:52:01.5805157Z ##[debug]Sql Version Specific Root Dir for version 130 as read from registry: C:\Program Files\Microsoft SQL Server\130\
2020-07-22T06:52:01.5860216Z ##[debug]Sql Version Specific Root Dir for version 130 as read from registry: C:\Program Files (x86)\Microsoft SQL Server\130\
2020-07-22T06:52:01.5912627Z ##[debug]Dac Framework installed with SQL Version 130 found at C:\Program Files (x86)\Microsoft SQL Server\130\Dac\bin\SqlPackage.exe on machine DBSERVER3
2020-07-22T06:52:01.7103800Z ##[debug]Dac Framework installed with SQL Version 130 found at C:\Program Files (x86)\Microsoft SQL Server\130\DAC\bin\SqlPackage.exe on machine DBSERVER3
2020-07-22T06:52:01.7487680Z ##[debug]Visual Studio versions found on machine DBSERVER3 as read from registry: 14.0 12.0 11.0 10.0 8.0
2020-07-22T06:52:01.8538116Z ##[debug]Visual Studio install location: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\
2020-07-22T06:52:01.8862724Z ##[debug]Dac Framework installed with Visual Studio found at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\140\SqlPackage.exe on machine DBSERVER3
2020-07-22T06:52:01.9186060Z ##[debug]File is C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac
2020-07-22T06:52:01.9520886Z ##[debug]Sqlpackage.exe arguments :  /SourceFile:"C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac" /Action:Publish /TargetServerName:"dbserver3\SQL2019" /TargetDatabaseName:"RIN.ActionDB_QA" /TargetUser:"rin" /TargetPassword:"password" 
2020-07-22T06:52:01.9551359Z ##[debug] /SourceFile:"C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac" /Action:Publish /TargetServerName:"dbserver3\SQL2019" /TargetDatabaseName:"RIN.ActionDB_QA" /TargetUser:"rin" /TargetPassword:"password" 
2020-07-22T06:52:01.9581010Z ##[debug]Executing command: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\140\SqlPackage.exe  /SourceFile:"C:\azagent\A1\_work\r1\a\_ActionAPI-CI-QA\artifact-actiondacpac-QA\New_sql_2019\bin\Release\New_sql_2019.dacpac" /Action:Publish /TargetServerName:"dbserver3\SQL2019" /TargetDatabaseName:"RIN.ActionDB_QA" /TargetUser:"rin" /TargetPassword:"password" 
2020-07-22T06:52:04.3004630Z *** Could not deploy package.
2020-07-22T06:52:04.3005647Z Unable to connect to master or target server 'RIN.ActionDB_QA'. You must have a user with the same password in master or target server 'RIN.ActionDB_QA'.
2020-07-22T06:52:04.3382043Z ##[debug]Deployment failed with error : Publishing to database 'RIN.ActionDB_QA' on server 'dbserver3\SQL2019'. 
2020-07-22T06:52:04.3409470Z ##[debug]Initializing deployment (Start) 
2020-07-22T06:52:04.3435795Z ##[debug]Initializing deployment (Failed) 
2020-07-22T06:52:04.3458533Z ##[debug]
2020-07-22T06:52:04.3706793Z ##[debug]Write-Exception error:
2020-07-22T06:52:04.3786790Z ##[debug]Publishing to database 'RIN.ActionDB_QA' on server 'dbserver3\SQL2019'. 
2020-07-22T06:52:04.3813415Z ##[debug]Initializing deployment (Start) 
2020-07-22T06:52:04.3833536Z ##[debug]Initializing deployment (Failed) 
2020-07-22T06:52:04.3852670Z ##[debug]
2020-07-22T06:52:04.3908319Z ##[debug]Caught exception from task script.
2020-07-22T06:52:04.3958204Z ##[debug]Error record:
2020-07-22T06:52:04.5313400Z ##[debug]Publishing to database 'RIN.ActionDB_QA' on server 'dbserver3\SQL2019'. 
2020-07-22T06:52:04.5347974Z ##[debug]Initializing deployment (Start) 
2020-07-22T06:52:04.5381991Z ##[debug]Initializing deployment (Failed) 
2020-07-22T06:52:04.5419891Z ##[debug]
2020-07-22T06:52:04.5452059Z ##[debug]At C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\ps_modules\TaskModuleSqlUtility\SqlPackageOnTargetMachines.ps1:567 char:10
2020-07-22T06:52:04.5478252Z ##[debug]+          throw  $result
2020-07-22T06:52:04.5504801Z ##[debug]+          ~~~~~~~~~~~~~~
2020-07-22T06:52:04.5533945Z ##[debug]    + CategoryInfo          : OperationStopped: (Publishing to d...ent (Failed    ) 
2020-07-22T06:52:04.5561618Z ##[debug]:String) [], RuntimeException
2020-07-22T06:52:04.5591810Z ##[debug]    + FullyQualifiedErrorId : Publishing to database 'RIN.ActionDB_QA' on serv    er 'dbserver3\SQL2019'. 
2020-07-22T06:52:04.5620739Z ##[debug]Initializing deployment (Start) 
2020-07-22T06:52:04.5649754Z ##[debug]Initializing deployment (Failed) 
2020-07-22T06:52:04.5678829Z ##[debug]
2020-07-22T06:52:04.5709899Z ##[debug] 
2020-07-22T06:52:04.5759021Z ##[debug]Script stack trace:
2020-07-22T06:52:04.5857807Z ##[debug]at ExecuteCommand, C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\ps_modules\TaskModuleSqlUtility\SqlPackageOnTargetMachines.ps1: line 567
2020-07-22T06:52:04.5888012Z ##[debug]at Invoke-DacpacDeployment, C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\ps_modules\TaskModuleSqlUtility\SqlPackageOnTargetMachines.ps1: line 534
2020-07-22T06:52:04.5916543Z ##[debug]at <ScriptBlock>, C:\azagent\A1\_work\_tasks\SqlDacpacDeploymentOnMachineGroup_4b506f7f-720f-47bb-bf21-029bac6a690d\0.3.23\Main.ps1: line 124
2020-07-22T06:52:04.5944487Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-07-22T06:52:04.5974238Z ##[debug]at <ScriptBlock>, <No file>: line 22
2020-07-22T06:52:04.6012463Z ##[debug]at <ScriptBlock>, <No file>: line 18
2020-07-22T06:52:04.6042594Z ##[debug]at <ScriptBlock>, <No file>: line 1
2020-07-22T06:52:04.6092535Z ##[debug]Exception:
2020-07-22T06:52:04.6195130Z ##[debug]System.Management.Automation.RuntimeException: Publishing to database 'RIN.ActionDB_QA' on server 'dbserver3\SQL2019'. 
2020-07-22T06:52:04.6216331Z ##[debug]Initializing deployment (Start) 
2020-07-22T06:52:04.6238196Z ##[debug]Initializing deployment (Failed) 
2020-07-22T06:52:04.6259708Z ##[debug]
2020-07-22T06:52:04.6809953Z ##[error]Publishing to database 'RIN.ActionDB_QA' on server 'dbserver3\SQL2019'. 
Initializing deployment (Start) 
Initializing deployment (Failed) 

2020-07-22T06:52:04.6830979Z ##[debug]Processed: ##vso[task.logissue type=error]Publishing to database 'RIN.ActionDB_QA' on server 'dbserver3\SQL2019'. %0D%0AInitializing deployment (Start) %0D%0AInitializing deployment (Failed) %0D%0A
2020-07-22T06:52:04.6834571Z ##[debug]Processed: ##vso[task.complete result=Failed]
2020-07-22T06:52:04.7507980Z ##[section]Finishing: Deploy using : dacpac

Solution

  • From the deploy log, I notice that you are using the Deployment Group to run the Sql database deploy task.

    The Sql database deploy task calls sqlpackage.exe on your local machine.

    In the log, I also notice that the task is using the sqlpackage.exe from the Microsoft Visual Studio 14.0 folder. It seems that this folder is for visual studio 2015 instead of visual studio 2019.

    On local machine the sqlpackage.exe exists in the path:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150

    Here are the sample script, you could refer to it:

    cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150
    
    SqlPackage.exe  /SourceFile:"C:\xxx\FIle\filename.dacpac" /Action:Publish /TargetServerName:"KEVINL\SQLEXPRESS" /TargetDatabaseName:"Testkevin6" /TargetUser:"MyNewAdminUser" /TargetPassword:"xxx"
    

    enter image description here

    You could try to use the sqlpackage.exe from visual studio 2019. If it could work, you could try to change the agent environemnt value.