【问题标题】:Connecting to ODBC driver from azure function从 azure 函数连接到 ODBC 驱动程序
【发布时间】:2021-07-23 13:58:05
【问题描述】:

我目前正在开发一个连接到 odbc 驱动程序的 azure 函数。我有一个本地称为“Dobbe WMS productie”,我正在使用以下代码连接到它。

using(odbcConnection conn = new OdbcConnection("DSN=Dobbe WMS productie"))
{
    conn.Open();
    // performs some actions
    conn.Close();
}

在本地这工作得很好。现在我将它发布到 azure 并且它无法正常工作,正如我所料。问题是,我找不到任何东西来解决我的问题。有没有人可以帮助我解决这个问题?

编辑:
我的完整错误消息:ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.

我在 windows -> System-DSN -> add 上打开了 ODBC-datasources,然后选择 postgresql ansi 驱动程序。填写表格中的基本信息并点击保存

我也尝试过 Npgsl 并得到以下错误: The remote certificate is invalid according to the validation procedure. 我的连接字符串看起来像这样:Server=address;Port=5432;Database=dbname;User Id=username;Password=password;SslMode=Require

【问题讨论】:

  • I cant find anything to solve my issue 你部署驱动了吗?您是否创建了数据源?你得到了什么错误?
  • 您好@PanagiotisKanavos,感谢您的快速回复!我还没有做任何事情,比如部署它。如果您参考了一些文档,我将不胜感激。也看看编辑
  • 嗯,你读过错误的内容吗?您希望如何连接到不存在的数据源? a reference to some documentation你是如何在你的机器上设置数据源的?
  • @PanagiotisKanavos 我知道它在说什么。我预计会出现这样的错误,因为我有本地驱动程序。但我不知道从哪里开始才能从 azure 访问它

标签: c# azure azure-functions


【解决方案1】:

感谢@rene 的帮助,我成功地使用了 NpgSQL。在深入了解服务点经理后,我发现我必须做一件小事。将连接字符串修改为如下内容:

Server=address;Port=5432;Database=dbname;User Id=username;Password=password;SslMode=Require;Trust Server Certificate=true

【讨论】:

    猜你喜欢
    • 2013-11-11
    • 2020-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-24
    • 1970-01-01
    • 1970-01-01
    • 2020-05-02
    相关资源
    最近更新 更多