![](/img/trans.png)
[英]Can you use a sql server alias to connect to azure using active directory integrated authentication?
[英]How to connect to Azure SQL Server in databricks using active directory authentication
在下面的代碼中,我使用SQL Server用戶ID和密碼連接到我的數據庫。
但是在連接活動目錄時出錯。
請建議使用Active Directory身份驗證在Azure Databricks中連接Azure SQL Server數據庫的一些解決方案。
截至目前,我能夠連接JDBC連接:
sql_url="jdbc:sqlserver://kkk-server.database.windows.net:1433;database=database;user=UserName;password=Password"
根據Azure數據庫文檔使用Spark Connector連接到Microsoft SQL Server和Azure SQL數據庫 :
SQL Server和Azure SQL數據庫的Spark連接器還支持Azure Active Directory(AAD)身份驗證。 它允許您使用AAD帳戶從Azure Databricks安全地連接到Azure SQL數據庫。
示例: 從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()
用您的AD帳戶名替換用戶。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.