来自 Azure Func 或逻辑应用程序的 OleDB 或 ODBC

OleDB or ODBC from Azure Func or Logic App

我有一个使用 Access 数据库(.mdb 文件)的遗留应用程序。基本上它读取现有的 mdb 文件并填充新数据,这些数据由下游系统使用。我们无法摆脱 mdb 文件,它的功能非常重要,因为它被各种客户端使用。

我们需要将该应用程序迁移到 Azure,我们正在提议几个 Azure Func 和 Logic 应用程序。我们正在寻找实现此功能的可能选项。

作为一个 poc,当我尝试从本地的 AF 运行 访问 mdb 文件时,它在打开连接时失败了。

string connString = $"Driver={{Microsoft Access Driver (*.mdb, *.accdb)}};Dbq={dbFileName};";
        using (OdbcConnection connection = new OdbcConnection(connString))
        {
            try
            {
                connection.Open();
                OdbcDataReader reader = null;
                OdbcCommand command = new OdbcCommand("SELECT * from Table1", connection);
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    return (ActionResult)new OkObjectResult($"Found {reader["Field1"]}");
                }
            }catch(Exception ex)
            {
                log.LogError(ex, "something wrong");
            }
        }

相同的代码在控制台应用程序上运行良好。传递给连接的 mdb 文件路径是绝对本地路径。当在本地 Af 中不起作用时,我不确定这是否适用于 Azure。

我目前正在使用 "System.Data.Odbc - 4.5.0",我遇到的异常是

"Unable to load DLL 'libodbc.so.2' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

当我们无法从 AF 或 LogicApp 安装/使用 odbc/oledb 驱动程序时,我们如何访问/操作 mdb 文件。

除了使用 VM 之外,还有什么好的方法可以实现此功能。

我们不安装 Microsoft.Ace.we.12.0' 驱动程序。 服务器端环境不支持 Microsoft.Ace 驱动程序,并且没有计划将它们添加到 Azure Web Sites/Azure 功能,您也不可能添加它们。

这留下了使用已安装的 Jet 驱动程序的选项,但是这些仅在 32 位版本中可用,因此您必须将站点配置为 运行 在 32 位版本中。

Microsoft OLE DB Provider for Jet 和 Microsoft Access ODBC 驱动程序仅提供 32 位版本: http://support.microsoft.com/kb/957570/en-us