Azure 部署未安装 requirements.txt 中列出的 Python 包

Azure deployment not installing Python packages listed in requirements.txt

这是我第一次将 Flask Web 应用程序部署到 Azure。 我关注了这个tutorial

他们的默认演示应用程序对我来说很好用。

之后,我通过 git 推送了我的 Flask 应用程序。日志显示部署成功。但是,当我通过 "Application Properties" 中提供的 link 浏览托管应用程序时,出现如下 500 错误:

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.

通过 KUDU 浏览 wwwroot,我唯一能看到的不正常的事情是 none 我在本地虚拟环境中安装的软件包安装在 Azure 上,尽管 [=54] =] 文件在 wwwroot.

我的理解是,Azure 会在 GIT 成功推送后 pip 安装它在 requirements.txt 中找到的任何不存在的包。但它似乎并没有发生在我身上。

我是不是做错了什么,丢失的包裹只是一个症状,还是问题的根源?

备注:

我的 requirements.txt 有以下内容:

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

由于 Azure Web Apps 将 运行 一个 deploy.cmd 脚本作为部署任务,以控制部署期间哪些命令或任务将 运行。

您可以使用 Azure-CLI 命令 azure site deploymentscript --python 获取 python 应用程序的部署任务脚本。

你可以在这个 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.

因此.skipPythonDeployment将跳过部署任务中的所有后续步骤,包括创建虚拟环境。

您可以尝试从您的应用程序中删除 .skipPythonDeployment,然后重试。

此外,请参阅https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script了解更多信息。