DacFx: Unable to read data-tier application registration after Publish using SqlPackage
Here are the steps to reproduce the problem I met:
-
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
-
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 /TargetTrustServerCertificate:true
-
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 /TargetTrustServerCertificate: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
-
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
-
If I delete the data-tier application and register it from SSMS. Then the above commands are all works.
-
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
isfalse
which means this don’t read the data-tier application registration. -
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?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 16 (3 by maintainers)
I’m having the same problem on current release:
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
Adding @dzsquared
A similar problem occurs when we try to update the database using the dacpac file through DacServices.Deploy from DacFx version 150.5164.1:
Pay attention to the inner exception, it is also thrown when trying to read the model for a drift report:
Still an issue with sqlpackage 16.1.8089.0
here are the options i’m publishing with that caused the issue
/p:BlockOnPossibleDataLoss=False /p:ExcludeObjectTypes="Permissions;RoleMembership;Credentials;Users" /p:IgnorePermissions=True /p:IgnoreRoleMembership=True /p:DropObjectsNotInSource=True /p:RegisterDataTierApplication=True /p:IncludeTransactionalScripts=True /p:BlockWhenDriftDetected=False
FWIW I was able to perform a deploy without any issue as long as I didn’t RegisterDataTierApplication in the options, - makes me think there’s an issue with the way that sqlpackage is writing the metadata into sql server since SSMS can’t read it either.
Drift Report is still broken for DacFx 19.1 (16.0.6161.0) and keeps resulting in the
Unable to read data-tier application registration
error.I also got this problem today. Does @pensivebrian and @dzsquared have some time to take a look on this issue?