[英]Why is the azure app service django deploy keep failing?
It's been 1 month and I still can't figure out what's wrong with me or app service in azure. 已经过了1个月了,我还是无法确定我或天蓝色的应用程序服务出了什么问题。
I used python 2.7 and django 1.11.3, with this requirements.txt 我使用python 2.7和django 1.11.3并带有此requirements.txt
beautifulsoup4==4.6.0 certifi==2017.7.27.1 chardet==3.0.4 Django==1.11.5 idna==2.6 olefile==0.44 Pillow==4.2.1 pytz==2017.2 requests==2.18.4 urllib3==1.22
beautifulsoup4 == 4.6.0 certifi == 2017.7.27.1 chardet == 3.0.4 Django == 1.11.5 idna == 2.6 olefile == 0.44枕头== 4.2.1 pytz == 2017.2个请求== 2.18.4 urllib3 = = 1.22
When I deploy with Local Git Repository to Azure Web Service(Python2.7, Windows) it doesn't seems to install the requirements. 当我将本地Git存储库部署到Azure Web服务(Python2.7,Windows)时,似乎没有安装要求。
I tried wheel but it doesn't do anything, and via scm powershell I failed to install any of the requirements, example: 我尝试了wheel,但是它什么也没做,通过scm powershell我无法安装任何要求,例如:
Python -m pip install django
Python -m pip安装Django
It gave me no permission error. 它没有给我权限错误。
On Azure WebApps, Python is installed default at the path D:\\Python27\\
which has no permission for users to do any write operations like command pip install <packages>
to install Python packages to libs
, besides under the path D:\\home\\
. 在Azure WebApps上,默认情况下将Python安装在路径
D:\\Python27\\
,该用户无权执行命令pip install <packages>
类的任何写操作,以将Python软件包安装到libs
,除了在路径D:\\home\\
。
So first you need to install a new Python runtime at the path D:\\home
via Kudu site extensions, as the figure below. 因此,首先您需要通过Kudu网站扩展在路径
D:\\home
下安装新的Python运行时,如下图所示。
Then, you can see the Python directory under D:\\home
which you have the write operation permission. 然后,您可以在
D:\\home
下看到您具有写操作权限的Python目录。
For installing Python packages you want, do the commands as below to install pip
tool. 要安装所需的Python软件包,请执行以下命令以安装
pip
工具。
D:\home> cd Python27
D:\home\Python27> curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1558k 100 1558k 0 0 5069k 0 --:--:-- --:--:-- --:--:-- 6546k
D:\home\Python27> python get-pip.py
Requirement already up-to-date: pip in d:\home\python27\lib\site-packages
Collecting wheel
Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
Installing collected packages: wheel
Successfully installed wheel-0.30.0
The next, you can install these packages via python -m pip install <package-name>
, such as python -m pip install django==1.11.5
as below. 接下来,您可以通过
python -m pip install <package-name>
安装这些软件包,例如python -m pip install django==1.11.5
,如下所示。
D:\home\Python27> python -m pip install django==1.11.5
Collecting django==1.11.5
Downloading Django-1.11.5-py2.py3-none-any.whl (6.9MB)
Collecting pytz (from django==1.11.5)
Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
Installing collected packages: pytz, django
As the offical document said, for Troubleshooting - Package Installation
, as below, like for package Pillow
need compiler for C code. 正如官方文档所述,对于
Troubleshooting - Package Installation
,如下所示,对于软件包Pillow
需要C代码编译器。
Troubleshooting - Package Installation
故障排除-软件包安装
Some packages may not install using pip when run on Azure.
在Azure上运行时,某些软件包可能无法使用pip安装。 It may simply be that the package is not available on the Python Package Index.
可能只是该软件包在Python软件包索引上不可用。 It could be that a compiler is required (a compiler is not available on the machine running the web app in Azure App Service).
可能是需要编译器(在Azure App Service中运行Web应用程序的计算机上没有编译器)。
You need to download package wheel files from here via command curl -o <wheel-file-name> <wheel-file-url>
on Kudu CMD, and install them via command python -m pip install <wheel-file-name>
. 您需要在Kudu CMD上通过命令
curl -o <wheel-file-name> <wheel-file-url>
从此处下载打包的wheel文件,并通过python -m pip install <wheel-file-name>
命令安装它们。
After installed all packages, you can upload your django webapp to D:\\home\\site\\wwwroot
, the file structure under this path looks like the offical sample that includes these directories app
, <your-django-project-name>
created by PTVS on VS 2017. 安装完所有软件包后,您可以将django webapp上传到
D:\\home\\site\\wwwroot
,此路径下的文件结构看起来像包含这些目录app
的正式示例 ,PTVS创建的<your-django-project-name>
目录在VS 2017上
Finally, please configure your web.config
file to make your app works. 最后,请配置您的
web.config
文件以使您的应用正常运行。
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="<your-django-project-name>.wsgi.application"/>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
<system.webServer>
<handlers>
<add name="PythonHandler" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\Python27\python.exe|D:\home\Python27\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
</handlers>
<rewrite>
<rules>
<rule name="Static Files" stopProcessing="true">
<conditions>
<add input="true" pattern="false" />
</conditions>
</rule>
<rule name="Configure Python" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
</conditions>
<action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Hope it helps. 希望能帮助到你。 Any concern, please feel free to let me know.
如有任何疑问,请随时告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.