You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用用户分配托管标识实现Azure Databricks与Azure Synapse的正确连接

使用用户分配托管标识从Databricks连接Azure Synapse的正确配置

问题根源

你的JDBC URL格式错误:User Id与Authentication参数之间缺少分号分隔,且使用用户分配托管标识(UMSI)时未正确指定标识ID,导致连接器无法识别有效凭证。

正确配置代码

以下是使用用户分配托管标识连接Synapse专用池的正确PySpark代码,包含两种可行格式:

格式一:通过userAssignedIdentityId参数指定UMSI

df.write \
      .format("com.databricks.spark.sqldw") \
      .option("url", "jdbc:sqlserver://<synapse server name>.sql.azuresynapse.net;database=<dedicated pool name>;Authentication=ActiveDirectoryMSI;Use Encryption for Data=true;") \
      .option("useAzureMSI", "true") \
      .option("userAssignedIdentityId", "<umsi_synapse_user的Client ID或Object ID>") \
      .option("dbtable", "table_name") \
      .option("truncate", "false") \
      .option("tempDir", "abfss://<azure_storage_name>@<container_name>.dfs.core.windows.net/tempDir") \
      .mode("overwrite") \
      .save()

格式二:在JDBC URL中指定UMSI的ID

df.write \
      .format("com.databricks.spark.sqldw") \
      .option("url", "jdbc:sqlserver://<synapse server name>.sql.azuresynapse.net;database=<dedicated pool name>;User Id=<umsi_synapse_user的Client ID>;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()

关键修改说明

  • JDBC URL规范:确保参数间用分号分隔,Authentication=ActiveDirectoryMSI明确指定MSI认证方式
  • 用户分配标识指定:必须通过userAssignedIdentityId参数或URL中的User Id指定UMSI的Client ID/Object ID(从Azure门户的托管标识资源详情中获取)
  • 权限验证:确认umsi_synapse_user对ADLS Gen2临时目录拥有存储Blob数据参与者权限,确保临时文件读写正常

内容的提问来源于stack exchange,提问作者user1651818

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 18:40:00