使用外部Git存储库(Bitbucket)将Django应用(准确地说是wa)部署到Azure Web Services时遇到了挑战.我想使用Python 3.6.1,因此我遵循在Azure App Service手册上管理Python
I've got a challenge with deploying Django app (wagtail to be precise) to Azure Web Services using external Git repo (Bitbucket). I want to use Python 3.6.1, therefore I followed instructions at Managing Python on Azure App Service manual
- 我已安装并安装了python 3.6.1扩展
- 我在应用程序的根目录中创建了web.config文件(已检查并上传到服务器)
但是,部署失败并显示消息
However, deploy fails with message
Detecting Python runtime from runtime.txt Unsupported runtime: python-3.6.1 Supported runtime values are: python-2.7 python-3.4 An error has occurred during web site deployment. \r\nD:\Program Files (x86)\SiteExtensions\Kudu\66.61008.3066\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"我的web.config文件
My web.config file
<?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="PYTHONPATH" value="D:\home\site\wwwroot"/> <!-- Django apps only --> <add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()"/> <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/> </appSettings> <system.webServer> <handlers> <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python361x64\python.exe|D:\home\python361x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/> </handlers> </system.webServer> </configuration>路径还可以,下面是Kudu控制台中的ls
Paths are ok, below is ls from Kudu console
D:\home\python361x64>ls DLLs Lib Scripts __pycache__ python.exe python3.dll python36.dll pythonw.exe sitecustomize.py vcruntime140.dll wfastcgi.py似乎部署过程没有考虑到我拥有的web.config文件,或者通过扩展名安装的python版本不可见.
It looks like the deployment process is not taking into account the web.config file that I have, or the python version that I've installed via extensions is not visible.
能否请您告诉我可能的问题在哪里?
Could you please tell me where the possible issue could be?
最诚挚的问候, 康拉德
Best regards, Konrad
推荐答案经过几个小时的战斗,我终于设法按预期运行了这个混蛋;)
After a couple of hours of fighting, I finally managed to run this bastard as expected ;)
感谢@Jay Gong在本教程的逐步介绍中为您提供了一些信息.
Thanks, @Jay Gong for your input as going step by step with this tutorial showed me a couple of things.
我在根文件夹中拥有的删除runtime.txt后,部署过程一直在使用python 3.4,并且无法安装requirements.txt文件中的依赖项之一(可能是由于python的较旧版本).因此,下一步是添加.skipPythonDeployment,以避免自动安装需求,并通过kudu控制台手动安装需求.在带有我们的python env的文件夹(在我的情况下为D:\home\python361x64)中,以下命令已启动 python.exe -m pip install --upgrade -r D:\home\site\wwwroot\requirements.txt 所有依赖项均已正确安装.
When runtime.txt had been removed, deployment process has been using python 3.4 and was failing on installation one of the dependencies from requirements.txt file (probably because of the older version of python). So the next step was to add .skipPythonDeployment, to avoid automatic installation of requirements and install those manually by kudu console. In folder with our python env (in my case D:\home\python361x64) following command was launched python.exe -m pip install --upgrade -r D:\home\site\wwwroot\requirements.txt All dependencies were installed correctly.
部署后,在Web浏览器中启动应用程序时显示消息The page cannot be displayed because an internal server error has occurred..下一步是收集有关该问题的更多信息,因此我在web.config文件中添加了几行:
After deploy, launching an app in a web browser showed message The page cannot be displayed because an internal server error has occurred.. Next step was to gather more info about the issue, so I have added a few new lines in web.config file:
.... <system.webServer> .... <httpErrors errorMode="Detailed"></httpErrors> </system.webServer> <system.web> .... <customErrors mode="Off" /> </system.web>谢谢,我能够检查是什么导致了问题.就我而言,它是web.config中的WSGI_HANDLER值.我将其设置为正确的值(对于w来说,它是<app_name>.wsgi.application,然后开始工作.
Thanks to that, I was able to check what is causing the issue. In my case, it was a WSGI_HANDLER value in web.config. I set it to a correct value (for wagtail it was <app_name>.wsgi.application and then it started working.
谢谢大家的支持.
更多推荐
在Azure应用程序服务上使用python 3.6
发布评论