Azure deployment not installing Python packages listed in requirements.txt

一曲冷凌霜 提交于 2021-01-01 04:55:09

问题


This is my first experience deploying a Flask web app to Azure. I followed this tutorial.

The default demo app they have works fine for me.

Afterwards, I pushed my Flask app via git. The log shows deployment was successful. However, when I browse the hosted app via link provided in "Application Properties", I get a 500 error as follows:

The page cannot be displayed because an internal server error has occurred.

Most likely causes: IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred. IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly. IIS was not able to process configuration for the Web site or application. The authenticated user does not have permission to use this DLL. The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.

The only off-base thing I can see by browsing the wwwroot via KUDU is that none of the packages I have installed in my local virtual environment are installed on Azure despite the existence of the "requirements.txt" file in wwwroot.

My understanding is that Azure would pip install any non existent package that it finds in the requirements.txt upon GIT successful push. But it doesn't seem to be happening for me.

Am I doing something wrong and the missing packages is just a symptom or could it be the cause the issue?

Notes:

  • My Flask app works fine locally (linux) and on a 3rd party VPS

  • I redeployed several times starting from scratch to no avail (I use local GIT method)

  • I cloned the Azure Flask demo app locally, changed just the app folder and pushed back to Azure, yet no success.

  • Azure is set to Python 2.7 same as my virtual env locally

  • As suggested in the tutorial linked above, I deleted the "env" folder and redeployed to trick Azure to reinstall the virtual env. It did but with its own default packages not the one in my requirements.txt.

My requirements.txt has the following:

bcrypt==3.1.0 cffi==1.7.0 click==6.6 Flask==0.11.1 Flask-Bcrypt==0.7.1 Flask-Login==0.3.2 Flask-SQLAlchemy==2.1 Flask-WTF==0.12 itsdangerous==0.24 Jinja2==2.8 MarkupSafe==0.23 pycparser==2.14 PyMySQL==0.7.7 python-http-client==1.2.3 six==1.10.0 smtpapi==0.3.1 SQLAlchemy==1.0.14 Werkzeug==0.11.10 WTForms==2.1


回答1:


As Azure Web Apps will run a deploy.cmd script as the deployment task to control which commands or tasks will be run during the deployment.

You can use the command of Azure-CLI azure site deploymentscript --python to get the python applications' deployment task script.

And you can find the following script in this deploy.cmd sciprt:

IF NOT EXIST "%DEPLOYMENT_TARGET%\requirements.txt" goto postPython
IF EXIST "%DEPLOYMENT_TARGET%\.skipPythonDeployment" goto postPython

echo Detected requirements.txt.  You can skip Python specific steps with a .skipPythonDeployment file.

So the .skipPythonDeployment will skip all the following steps in deployment task, including creating virtual environment.

You can try to remove .skipPythonDeployment from your application, and try again.

Additionally, please refer to https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script for more info.



来源:https://stackoverflow.com/questions/39840209/azure-deployment-not-installing-python-packages-listed-in-requirements-txt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!