简体   繁体   English

如何使用Active Directory身份验证在databricks中连接到Azure SQL Server

[英]How to connect to Azure SQL Server in databricks using active directory authentication

In the below code I am using SQL Server user id and password to connect to my db. 在下面的代码中,我使用SQL Server用户ID和密码连接到我的数据库。

But I get an error while connecting with active directory. 但是在连接活动目录时出错。

Please Suggest some solution to connect Azure SQL Server DB in Azure Databricks using Active Directory authentication. 请建议使用Active Directory身份验证在Azure Databricks中连接Azure SQL Server数据库的一些解决方案。

As of now, I am able to connect with a JDBC connection: 截至目前,我能够连接JDBC连接:

sql_url="jdbc:sqlserver://kkk-server.database.windows.net:1433;database=database;user=UserName;password=Password"

According the Azure databricks document Connecting to Microsoft SQL Server and Azure SQL Database with the Spark Connector : 根据Azure数据库文档使用Spark Connector连接到Microsoft SQL Server和Azure SQL数据库

The Spark connector for SQL Server and Azure SQL Database also supports Azure Active Directory (AAD) authentication. SQL Server和Azure SQL数据库的Spark连接器还支持Azure Active Directory(AAD)身份验证。 It allows you to securely connect to your Azure SQL databases from Azure Databricks using your AAD account. 它允许您使用AAD帐户从Azure Databricks安全地连接到Azure SQL数据库。

Example: Read from Azure SQL Database or SQL Server : 示例: 从Azure SQL数据库或SQL Server中读取

import com.microsoft.azure.sqldb.spark.config.Config
import com.microsoft.azure.sqldb.spark.connect._

val config = Config(Map(
  "url"            -> "kkk-server.database.windows.net:1433",
  "databaseName"   -> "MyDatabase",
  "dbTable"        -> "dbo.Clients",
  "user"           -> "AD-account",
  "password"       -> "xxxxxxxx",
  "connectTimeout" -> "5", //seconds
  "queryTimeout"   -> "5"  //seconds
))

val collection = spark.read.sqlDB(config)
collection.show()

Replace the user with your AD account name. 用您的AD帐户名替换用户。

Hope this helps. 希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您可以使用 sql server 别名通过活动目录集成身份验证连接到 azure 吗? - Can you use a sql server alias to connect to azure using active directory integrated authentication? 如何连接到 sql azure 数据库与 python Z9778840A0100CB30C982876741B0B5yA 使用集成的身份验证 - How to connect to the sql azure database with python SQL alchemy using active directory integrated authentication 使用 Azure Active Directory 作为身份验证方法时,SqlClient 如何获取 Azure SQL 服务器的“范围”? - How does SqlClient gets 'scope' of Azure SQL Server when using Azure Active Directory as authentication method? Azure SQL 使用 Azure Active Directory 进行身份验证 - Azure SQL authentication using Azure Active Directory 如何使用 Active Directory 身份验证从 Tableau Desktop 访问 Azure SQL 服务器/数据库 - How to Access Azure SQL Server/Database from Tableau Desktop using Active Directory Authentication Azure function - 使用 Active Directory 交互式身份验证连接到 Azure SQL 数据库 - Azure function - connect to Azure SQL database using Active Directory Interactive authentication 无法使用 Authentication=Active Directory Managed Identity 从 do.net web 应用程序连接到 Azure SQL MI - Unable to connect to Azure SQL MI from dotnet web application using Authentication=Active Directory Managed Identity 使用 Azure Active Directory 从 Azure 网站连接到 Azure SQL? - Connect to Azure SQL using Azure Active Directory from an Azure Website? 将 Liquibase 与 Azure SQL 和 Azure Active Directory 身份验证结合使用 - Using Liquibase with Azure SQL And Azure Active Directory Authentication 使用 Azure Active Directory Service Principal 身份验证为 Keycloak 配置 SQL 服务器 - Configure SQL Server with Azure Active Directory Service Principal authentication for Keycloak
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM