โ12-02-2025 12:06 PM
I am trying to use the Databricks Python SDK (v 0.63.0) to create a Unity Catalog connection to a Azure-hosted SQL Server database using an Azure service principal to authenticate. I have successfully done this via the Workspace UI, but I am trying to replicate programmatically it using the Databricks Python SDK.
Below is the code that I am trying to use to create the connection, but it doesn't authenticate successfully. The login to SQL Server fails when I try to create a foreign catalog using the connection.
โ12-02-2025 01:16 PM - edited โ12-02-2025 01:29 PM
Hi @ScottH ,
You need to configure it in following way (I've tested it and it works). In a place where a red arrow is pointing you need to provide your own tenant_id:
โ12-02-2025 12:34 PM
@ScottH Can you please try this in options.
options={
"host": "<sql-server-host>.database.windows.net",
"port": "1433",
"authentication": "ActiveDirectoryServicePrincipal",
"client_id": "<service-principal-client-id>",
"client_secret": "<service-principal-client-secret>",
"tenant_id": "<azure-ad-tenant-id>",
"applicationIntent": "ReadOnly",
"trustServerCertificate": "true"
}
โ12-02-2025 01:16 PM - edited โ12-02-2025 01:29 PM
Hi @ScottH ,
You need to configure it in following way (I've tested it and it works). In a place where a red arrow is pointing you need to provide your own tenant_id:
โ12-02-2025 01:38 PM
Awesome! That worked perfectly! I really appreciate your help - you saved me a bunch of time. Thank you!
โ12-02-2025 01:40 PM
No problem @ScottH , cool that it worked for you ๐