首页 > 解决方案 > Connecting to ODBC driver from azure function

问题描述

I am currently working on an azure function that connects to a odbc driver. I have one locally called 'Dobbe WMS productie' and i am using the following code to connect to it.

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

Locally this works just fine. Now I published this to azure and it is not working, as i expected. The problem is, I cant find anything to solve my issue. Is there anyone that can help me with this?

EDIT:
My full error message: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.

I opened the ODBC-datasources on windows -> System-DSN -> add and then choose the postgresql ansi driver. Filled out the basics in the form and clicked on save

I have also tried Npgsl and got the following error: The remote certificate is invalid according to the validation procedure. my connection string looks something like this: Server=address;Port=5432;Database=dbname;User Id=username;Password=password;SslMode=Require

标签: c#azureazure-functions

解决方案


感谢@rene 的帮助,我设法让它与 NpgSQL 一起工作。在深入了解服务点经理后,我发现我必须做一件小事。它将连接字符串修改为如下内容:

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


推荐阅读