0

I'm using Azure App Service to make my website. The website worked fine on my localhost, using a sqllite database and SQLAlchemy. Now I am trying to switch to the Azure SQL DB using this: https://gist.github.com/timmyreilly/f4a351eda5dd45aa9d56411d27573d7c

I followed the directions, but I'm getting this error. I looked up the error and found this: pyodbc - error while running application within a container but it wasn't able to help because the solution there said to do sudo apt install unixodbc-dev, but Azure CLI doesn't let me use sudo so I'm not sure how I can do this. Can you guys help me, what should I do?

2019-02-15T00:55:28.174067202Z   File "/home/site/wwwroot/antenv/lib/python3.7/site-packages/sqlalchemy/connectors/pyodbc.py", line 38, in dbapi
2019-02-15T00:55:28.174070902Z     return __import__('pyodbc')
2019-02-15T00:55:28.174195702Z ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
Sheshank S.
  • 3,053
  • 3
  • 19
  • 39

1 Answers1

0

According to your error information and the @IvanYang comments, you deployed your Python app on Azure App Service for Linux Container which be based on Docker.

So you can refer to the offical document SSH support for Azure App Service on Linux to connect to the Linux system of your app to install the missing unixodbc-dev package via sudo apt install unixodbc-dev and then to make your app works before restart your app service.

The change of unixodbc-dev installed is temporary for docker container, you can refer to the existing SO thread Install unixodbc-dev for a Flask web app on Azure App Service to know it. The only way to keep it works is to add the content below into your .dockerfile file or to use a docker image which had been installed the required packages when create an App Service instance on Linux.

# Add unixodbc support
RUN apt-get update \
        && apt-get install -y --no-install-recommends unixodbc-dev
Peter Pan
  • 23,476
  • 4
  • 25
  • 43