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.

Unable to read data-tier application registration after Publish using SqlPackage

See original GitHub issue

Here are the steps to reproduce the problem I met:

  1. Run SQL Server Container for Linux

    docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Ver7CompleXPW" -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2019-latest
    
  2. Deploy ContosoUniversity.dacpac as data-tier application

    sqlpackage /Action:Publish /SourceFile:"ContosoUniversity.dacpac" /TargetDatabaseName:"ContosoUniversity" /TargetServerName:"." /TargetUser:sa /TargetPassword:Ver7CompleXPW /p:RegisterDataTierApplication=true /p:BlockWhenDriftDetected=true
    
  3. Deploy again using the exact same above command.

    sqlpackage /Action:Publish /SourceFile:"ContosoUniversity.dacpac" /TargetDatabaseName:"ContosoUniversity" /TargetServerName:"." /TargetUser:sa /TargetPassword:Ver7CompleXPW /p:RegisterDataTierApplication=true /p:BlockWhenDriftDetected=true
    

    Here is the output:

    Publishing to database 'ContosoUniversity' on server '.'.
    Initializing deployment (Start)
    Initializing deployment (Failed)
    *** Could not deploy package.
    Unable to read data-tier application registration.
    Time elapsed 0:00:10.68
    
  4. I’m trying to create a DriftReport

    sqlpackage /Action:DriftReport /TargetDatabaseName:"ContosoUniversity" /TargetServerName:"." /TargetUser:sa /TargetPassword:Ver7CompleXPW /OutputPath:DriftReport.xml
    

    Here is the output:

    Generating drift report for database 'ContosoUniversity' on server '.'.
    *** Could not generate drift report.
    Unable to read data-tier application registration.
    Time elapsed 0:00:00.64
    
  5. If I delete the data-tier application and register it from SSMS. Then the above commands are all works.

  6. If I use the following command to publish again.

    sqlpackage /Action:Publish /SourceFile:"ContosoUniversity.dacpac" /TargetDatabaseName:"ContosoUniversity" /TargetServerName:"." /TargetUser:sa /TargetPassword:Ver7CompleXPW /p:RegisterDataTierApplication=true /p:BlockWhenDriftDetected=false
    

    Note: the /p:BlockWhenDriftDetected is false which means this don’t read the data-tier application registration.

  7. Then the /Action:DriftReport still showing Unable to read data-tier application registration.* error message.

    sqlpackage /Action:DriftReport /TargetDatabaseName:"ContosoUniversity" /TargetServerName:"." /TargetUser:sa /TargetPassword:Ver7CompleXPW /OutputPath:DriftReport.xml
    

    logs:

    Generating drift report for database 'ContosoUniversity' on server '.'.
    *** Could not generate drift report.
    Unable to read data-tier application registration.
    Time elapsed 0:00:00.64
    

Is this a bug?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
nmbellcommented, Dec 12, 2022

I’m having the same problem on current release:

  • Version number: 161.6374.0
  • Build number: 16.1.6374.0
  • Release date: November 9, 2022

I tested against SQL Server versions 2014 through 2019. I’ve attached a complete repo script with my output.

@llali Can you re-open? You didn’t mention what version of SqlPackage you tested with (the content of the page you linked to will change with each release), but if the problem wasn’t there in the version you tested, it seems it’s back in the current version. SqlPackageTest.zip

2reactions
pensivebriancommented, Jun 21, 2021

Adding @dzsquared

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating Data-Tier Application version via SqlPackage.exe
In my testing, I've found that setting RegisterDataTierApplication to true is performing an upgrade if the target database is already registered ...
Read more >
Registering a SSDT database project as a data tier ...
I am trying to publish the project as a data tier application but keep receiving the following error "Databases registered as a DAC...
Read more >
Register a Database As a DAC - SQL Server
Use the Register Data-tier Application Wizard ... Complete the wizard dialogs: Introduction Page. Set Properties Page. Validation and Summary Page.
Read more >
Could not deploy package error when you ...
To retrieve data from a packaged app, extract the *.DACPAC file, and then deploy the data-tier application to SQL Server.
Read more >
Advanced usages of Data-Tier applications
This article will show the advanced usages of Data Tier Applications using SQLCMD variables and Publish Profiles.
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