GithubHelp home page GithubHelp logo

easonlai / databricks_odbc_connection_to_azure_sql_db_with_azure_ad_user_access_token Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 100 KB

Making ODBC connection from Databricks (Azure Databricks) to Azure SQL Database with Azure AD User Access Token.

HTML 68.04% Jupyter Notebook 31.96%
databricks databricks-notebooks azure azuredatabricks pyodbc azuread pandas azuresqldb azuresql spark odbc odbc-driver microsoftazure microsoft microsoft-azure bigdata dataanalysis dataanalytics datascience data-analysis

databricks_odbc_connection_to_azure_sql_db_with_azure_ad_user_access_token's Introduction

Databricks ODBC Connection to Azure SQL Database with Azure AD User Access Token

This code repository is showing how to make ODBC connection from Azure Databricks to Azure SQL Database with Azure AD user access token. Databricks doesn’t supported for Azure AD user passthrough authentication to Azure SQL Database and only supported for Azure Data Lake Storage (ADLS). Due to this limitation, we’re only able to use Azure AD Service Principle (or primitive SQL ID) to make authentication with Azure SQL Database. And we’re also required to setup (Databricks Secret Scope maybe also using Azure Key Vault-backed scope in advanced scenario) with corresponding access control to save the Azure AD Service Principle secrets. This make lots of administration and operation overhead on Databricks Secret Scope. And Azure AD Service Principle based authentication is also hard to trace/audit database access as Secret Scope can be shared.

To make our life easier, I’m trying to make interactive authentication with Azure AD from Databricks notebook and obtain the access token. And then use pyodbc to make token-based authentication with Azure SQL Database.

  1. Analyst use browser to interact Azure Databricks with Notebook.
  2. Initiate interactive authentication (with device code) from Notebook. Open up additional tab from browser (https://microsoft.com/devicelogin) to perform interactive authentication with Azure AD.
  3. After login successful, Notebook user session will get the user access token from Azure AD.
  4. Leverage collected access token to perform token-based authentication with Azure SQL Database via pyodbc library and MS-SQL driver, load SQL query into Panda dataframe, then covert Panda dataframe into Spark dataframe.

diagram1

All data in this code repository is coming from classic dataset of diabetes classification.

Enjoy!

databricks_odbc_connection_to_azure_sql_db_with_azure_ad_user_access_token's People

Contributors

easonlai avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.