Skip to content

AdoProvider with AzureAD authentication #1036

Answered by lahma
Cisien asked this question in Q&A
Discussion options

You must be logged in to vote

I think that you can get away with something like this (pseudocode mostly).. Edited after morning coffee kicked in

    public class AzureAadProvider : DbProvider
    {
        // here passing known supported DB provider name to base class
        public AzureAadProvider(string connectionString)
            : base("SqlServer", connectionString)
        {
        }

        public override DbConnection CreateConnection()
        {
            var connection = base.CreateConnection();
            var tokenProvider = new AzureServiceTokenProvider();
            connection.AccessToken = await tokenProvider.GetAccessTokenAsync("https://database.windows.net/");
            return connection;

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Cisien
Comment options

@Cisien
Comment options

@Diaskhan
Comment options

Answer selected by Cisien
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants