本文介绍了如何在Azure应用服务上访问ODBC驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在连接到Azure SQL数据库的Linux上的Azure App Service上运行Django(3.0)应用程序.在我的暂存App Service实例中,这可以完美地工作,但是,当我在其他Azure帐户上设置生产实例时,我的Django应用程序将无法再访问数据库.

当我将ODBC Driver 17硬编码到数据库设置中时,我的Oryx构建日志中出现了此错误:

  pyodbc.Error :("01000","[01000] [unixODBC] [Driver Manager]无法打开lib'SQL Server的ODBC驱动程序17':找不到文件(0)(SQLDriverConnect)") 

当我切换到非硬编码版本时,建议在

然后我们可以使用隐私模式,或在清除缓存后访问网站.您可以尝试刷新几次,然后发现网站恢复正常.

之前,我说过您可以尝试使用venv,经过测试,我发现它不需要使用.按照我的步骤运行命令,您的Web应用就可以了.

I'm trying to run a Django (3.0) app on Azure App Service in Linux, connected to an Azure SQL Database. In my staging App Service instance, this works perfectly, however, when I set up my production instance on a different Azure account, my Django app can no longer access the database.

When I hardcoded the ODBC Driver 17 into database settings, I got this error in my Oryx build logs:

pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")

When I switched to the non-hardcoded version suggested here, I got this error:

    'driver': sorted(pyodbc.drivers()).pop(),
IndexError: pop from empty list

How does one go about installing an ODBC Driver on Azure App Service?

EDIT: I am not using the Docker deploy option. I am deploying source code directly from Github.

解决方案

I have tested it and it works for me.

Open ssh to you web app and run the below command:-

Then we can use the privacy mode, or visit the website after clearing the cache. You can try to refresh a few more times and you will find that the website is back to normal.

Previous I said you can try to use venv, after I tested, I found it doesn't need to use it. Follow my step to run the command, you webapp will be ok.

这篇关于如何在Azure应用服务上访问ODBC驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 22:54