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

Azure App Service中ASP.NET应用连接Databricks SQL Warehouse的ODBC驱动名称咨询

解决方案:Azure App Service无驱动安装时连接Databricks SQL Warehouse

核心方案:利用Azure App Service预装的通用ODBC驱动

Azure App Service的Windows实例默认预装了多款通用ODBC驱动,无需额外安装权限就能直接使用。针对Databricks SQL Warehouse,推荐以下两种可行的驱动选择:

1. ODBC Driver 18 for SQL Server

这是最常用的预装驱动,兼容Databricks ODBC端点。无DSN连接字符串格式如下:

Driver={ODBC Driver 18 for SQL Server};Server=<databricks-server-hostname>;Port=443;Database=<catalog.schema>;Uid=token;Pwd=<your-databricks-token>;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;HTTPPath=<sql-warehouse-http-path>

替换占位说明:

  • <databricks-server-hostname>:Databricks SQL Warehouse的服务器地址(例如adb-xxxxxx.xx.azuredatabricks.net)
  • <catalog.schema>:目标目录与Schema(例如hive_metastore.default)
  • <your-databricks-token>:你的Databricks个人访问令牌
  • <sql-warehouse-http-path>:SQL Warehouse的HTTP路径(例如/sql/1.0/warehouses/xxxxxxxxx)

2. Microsoft ODBC Driver for Azure SQL Database

若第一种驱动存在兼容性问题,可尝试此预装驱动,连接字符串格式类似:

Driver={Microsoft ODBC Driver for Azure SQL Database};Server=<databricks-server-hostname>;Port=443;Database=<catalog.schema>;Uid=token;Pwd=<your-databricks-token>;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;HTTPPath=<sql-warehouse-http-path>

确认可用驱动列表

你可以通过Azure App Service的Kudu控制台(访问https://<your-app-name>.scm.azurewebsites.net/)执行以下命令,导出所有预装驱动:

odbcconf /s /q /l %temp%\odbc_drivers.txt

打开生成的odbc_drivers.txt文件,即可看到完整的驱动名称列表,直接复制对应名称到连接字符串即可。

ASP.NET代码使用示例

在项目中直接用上述连接字符串初始化ODBC连接:

using System.Data.Odbc;

var connectionString = "Driver={ODBC Driver 18 for SQL Server};Server=adb-xxxxxx.xx.azuredatabricks.net;Port=443;Database=hive_metastore.default;Uid=token;Pwd=your-token-here;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;HTTPPath=/sql/1.0/warehouses/xxxxxxxxx";

using (var connection = new OdbcConnection(connectionString))
{
    connection.Open();
    // 执行查询逻辑
    using (var command = new OdbcCommand("SELECT * FROM your_table", connection))
    {
        using (var reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                // 处理数据逻辑
            }
        }
    }
}

内容的提问来源于stack exchange,提问作者Mathias Rönnlund

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 11:17:06