question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SqlAzureDacpacDeployment fails on Hosted Windows 2019 agent

See original GitHub issue

Required Information

Question, Bug, or Feature?
Type: Bug

Enter Task Name: SqlAzureDacpacDeployment

Environment

  • Server - Azure Pipelines
  • Agent - Hosted:
    • If using Hosted agent, provide agent queue name: Hosted Windows 2019 with VS2019

Issue Description

Looks like a bug was introduced in one of the recent versions of sqlpackage.exe Publish is working on our private agents with the older version of sqlpackage but fails on most recent hosted Windows 2019. With the more recent version the publish command it still gets some bits from connection string specified in publish profile.

Here is the command line from SqlAzureDacpacDeployment task:

C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Publish /SourceFile:"d:\Database.dacpac" /TargetServerName:"*****" /TargetDatabaseName:"*****" /TargetUser:"***" /TargetPassword:"********" /Profile:"d:\Database.publish.xml" /p:AllowIncompatiblePlatform=true 

It was working when the sqlpackage.exe was coming from the folder: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\140\SqlPackage.exe

Error I am getting:

Could not deploy package.
Unable to connect to target server '*****'. Please verify the connection information such as the server name, login credentials, and firewall rules for the target server.
Windows logins are not supported in this version of SQL Server.

If I remove TargetConnectionString from the publish profile, or change Integrated Security to False, then publish command works perfectly.

We did a comparison of decompiled versions of sqlpackage 140 and 150 and looks like for some reason builder.IntegratedSecurity is not set to false anymore when username and password are specified decompiled-comparison

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
IvanAlekseevcommented, Jul 30, 2019

@zarochi yes I omitted some stuff from the path to remove our artifacts name. We are using VS .sqlproj projects and they have publish profiles to set some publish settings. I am using classic releases, that’s the yml it shows for a publish task (I removed some names here as well)

- task: SqlAzureDacpacDeployment@1
  displayName: 'Azure SQL Publish'
  inputs:
    azureSubscription: '*****'
    ServerName: '$(database_server_name)'
    DatabaseName: *****
    SqlUsername: '$(database_admin_username)'
    SqlPassword: '$(database_admin_password)'
    DacpacFile: '$(System.DefaultWorkingDirectory)/_db/Database.dacpac'
    PublishProfile: '$(System.DefaultWorkingDirectory)/_db/Database.publish.xml'
    AdditionalArguments: '/p:AllowIncompatiblePlatform=true'
1reaction
IvanAlekseevcommented, Jul 29, 2019

@zarochi as a workaround we are now running powershell script to modify the profile and change Integrated Security to False:

$FileName = "$(System.DefaultWorkingDirectory)/..../Database.publish.xml"

((Get-Content -path $FileName -Raw) -replace 'Integrated Security=True','Integrated Security=False') | Set-Content -Path $FileName
Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploy to Azure SQL Database - Microsoft Learn
task: SqlAzureDacpacDeployment@1 displayName: Execute Azure SQL ... must use a self-hosted agent and have the tool installed on your agent.
Read more >
Azure SQL Server deployment Problems and Solution
Since hosted agent user won't have permission on the SQL server because of security reasons.Hence it will fail.
Read more >
Selenium Tests running locally but failing on Azure DevOps ...
Pipeline Steps: We are using an Azure Agent (windows 2019). 1 - We install Google chrome webdrive (its then configured on the code)....
Read more >
Handling Azure managed identity access to Azure SQL in an ...
MSI provides Azure Web Apps access to Azure resources like Azure SQL, Azure Key Vault, and to APIs like Microsoft Graph API using...
Read more >
Automatically Deploy your Database with Dacpac Packages ...
The SSDT project uses .NET Framework 4.8 which means that it runs only on Windows. Azure DevOps has a task to deploy dacpac...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found