Unable to connect to Azure Synapse from Azure Databricks - Notebook (PySpark) using JDBC, Using teh following JDBC url, getting exception:
jdbc:sqlserver://.sql.azuresynapse.net;database=;User Id=Authentication=ActiveDirectoryMSI;Use Encryption for Data=true;
Exception:
Caused by: java.lang.IllegalArgumentException: No JDBC credentials provided. You must specify JDBC credentials in either the URL or as user/password options, use Credential Passthrough, or set Service Principal Oauth2.0 authentication.
Code:
df.write \
.format("com.databricks.spark.sqldw") \
.option("url", "jdbc:sqlserver://<synapse server name>.sql.azuresynapse.net;database=<dedicated pool name>;User Id=<UserAssignedManageIdentity>Authentication=ActiveDirectoryMSI;Use Encryption for Data=true;
") \
.option("useAzureMSI","true") \
.option("dbtable", "table_name") \
.option("truncate","false") \
.option("tempDir", "abfss://<azure_storage_name>@<container_name>.dfs.core.windows.net/tempDir") \
.mode("overwrite") \
.save()
What is the correct connection string to connect to Synapse using User Managed Service Identity.
Background:
- User Managed Service Identity (umsi_synapse_user) been created
- Assigned Contributor role to User Managed Service Identity to access Synapse
- Created External user with User Managed Service Identity (umsi_synapse_user)
- Assigned 'db_owner' role to umsi_synapse_user