Unable to deploy dacpac with Active Directory Interactive Authentication
See original GitHub issueI 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:
- Created 2 years ago
- Comments:14 (8 by maintainers)
Top GitHub Comments
@dzsquared could this be closed?
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