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 deploy dacpac with Active Directory Interactive Authentication

See original GitHub issue

I am attempting to deploy a dacpac to an Azure SQL Database using dacfx.

This works fine for Active Directory Password and Active Directory Integrated, however it does not work for Active Directory Interactive.

When using this connection string:

Data Source=testval.database.windows.net;authentication=active directory interactive;user id=jacob.alley@testval.com

and configuring my DacServices object like so:

var dacServiceInstance = new DacServices(connectionString);

I get the following error:

Cannot find an authentication provider for 'ActiveDirectoryInteractive'

After looking at the documentation, its clear that there is an overload for the controller that accepts an IUniversalAuthProvider instance. Looking online I see no classes that already implement this, so I decided to try and implement my own. It grabs the token and returns it in the GetValidAccessToken() method.

Now my call looks like this:

var authProvider = new AzureADAuth(connectionString);
                var dacServiceInstance = new DacServices(connectionString, authProvider);

When I run the deployment now, I am able to verify that my interface implementation is being called (by setting breakpoints), but after it returns the access token, it errors out with the following message:

InvalidOperationException: Cannot set the AccessToken property if 'UserID', 'UID', 'Password', or 'PWD' has been specified in connection string.

Ok so now I try and remove the username from the connection string before passing it in:

var authProvider = new AzureADAuth(connectionString);
                var builder = new SqlConnectionStringBuilder(connectionString);
                builder.Remove("User Id");
                var dacServiceInstance = new DacServices(builder.ConnectionString.Replace("ActiveDirectoryInteractive", "Active Directory Interactive"), authProvider);

This time my interface does not even get called and it fails with this error, demanding that I provide a userid:

Cannot use 'Authentication=Active Directory Interactive' without 'User ID' or 'UID' connection string keywords.

So in one step it requires the UserID and the other it says that it cannot be used with the UserId provided…

Please help provide a working example of how to deploy to an Active Directory Interactive endpoint using DacFx.

As a note, I am using the most up to date version of DacFX and also have the most recent version of System.Data.SqlClient installed as part of the project.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Feb 13, 2022

@dzsquared could this be closed?

1reaction
dzsquaredcommented, Sep 29, 2021

As to the GA date for DacFx 160 this is expected by end of the year.

As to the initially reported issue, yes if you use DacFx in .NET framework 4.6 you will use SDS by default.

Since this seems to be a greenfield project, is there consideration for using .NET core instead? You would immediately have support for MDS in DacFx 150. On .NET core I’m able to successfully execute the sample code above from @arvindshmicrosoft on DacFx 150.5164.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authentication Error in Azure Devops when Deploying DACPAC
However, when I ran my pipeline, I got the following error message: ##[error]*** Cannot use 'Authentication=Active Directory Interactive' with ' ...
Read more >
SQLPackage deploy a dacpac file using Universal ...
I now want to create db users that can connect with "Azure Active Directory - Universal with MFA" option in SSMS. For that...
Read more >
Troubleshooting failed DACPAC deployments
First you need to make sure that you are running the SqlPackage using the latest build. From the root folder of your local...
Read more >
SQLPackage requires a server login to deploy permissions?
Using sqlpackage.exe to deploy to an Azure SQL database using Azure Active Directory Universal / Interactive authententication With a user ...
Read more >
Azure SQL Database Deployment : Active Directory
We have a task to deploy SQL DB (dacpac file) using Azure SQL Publish task. This task uses Azure RM service connection with...
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