Skip to content

Authentication dialog opens for .NET Core when using Active Directory Interactive Authentication #735

@TechWatching

Description

@TechWatching

I have been using Microsft.Data.SqlClient in .NET Framework with Active Directory Interactive authentication and it worked great:

  • When running on Azure, the App Service's identity was used to connect to the database
  • When running locally, my Microsoft account was used to connect to the database
  • I had nothing to do it just worked

I have seen that Active Directory Interactive authentication is now available for .NET Core as well but it does not behave at all the same way. Each time I do a connection.OpenAsync() it launches an authentication dialog in my browser for me to log in with my account. Then my code can successfully make request to the database but I don't want to do a manual action each time my code runs locally.

Am I missing something ? My database connection string has the following format : "Server=tcp:sql-dev-myserver-data.database.windows.net,1433;Initial Catalog=db-dev-kpis;Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;Authentication=Active Directory Interactive;"
Is there a way to avoid this dialog and that my code connects to the database silently with my account already logged in in Visual Studio as it was doing in .NET Framework ? The solution I was using until now for .NET Core was to retrieve an access token and set it directly in the connection but that is something I was hoping to avoid now that Active Directory Interactive is supported in .NET Core.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions