【发布时间】:2021-04-03 22:04:46
【问题描述】:
我正在尝试将我的 Django 应用程序与 Azure DevOps 一起部署为 Azure Web 应用程序。该应用程序已流水线化并构建到 Web 应用程序,但它不会运行。
当我尝试在诊断控制台中运行 py manage.py runserver 时,我收到以下错误:
D:\Python34\python.exe: can't open file 'manage.py': [Errno 0] No error
有人知道问题可能是什么吗? 这是我尝试使用 Azure 部署的第一个项目,所以我的知识不是很好。 项目文件存储在服务器上的以下位置
D:\home\site\wwwroot\<applicationName>
我有时也会收到此错误:
Window title cannot be longer than 1023 characters.
文件结构
wwwroot
--- 应用程序名称
------ api
------ 应用程序名称
------ .env
------ db.sqlite3(空且未使用)
------ 管理.py
------ requirements.txt
已尝试解决问题的方法
- 根据 Jason Pan 的想法更改配置 -> 路径映射 -> 物理路径中的文件路径
- 添加 web.config 文件(添加到 wwwroot -> applicationname -> web.config)。配置文件粘贴在下面。这导致了以下错误:
The specified CGI application encountered an error and the server terminated the process.
Web.Config 文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*"
modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="D:\home\python364x64\python.exe" arguments="manage.py runserver %HTTP_PLATFORM_PORT%" requestTimeout="00:04:00" startupTimeLimit="120" startupRetryCount="3" stdoutLogEnabled="true">
<environmentVariables>
<environmentVariable name="PYTHONPATH" value="D:\home\site\wwwroot"/>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
感谢您的帮助。
解决方案
在 Jason Pan 的大力帮助下,我设法将其设置为容器服务,并且该应用程序现在可以正常运行!非常感谢杰森!
【问题讨论】:
-
请告诉我
wwwroot文件夹下的内容。 -
由于格式原因,我在原帖中添加了这个。
-
尝试用windows容器创建web应用^-^。
-
由于azure web app是sandbox env,所以不能再改了,需要使用容器web app。 imgur.com/a/hFbK04e
-
如果我的解决方案对您有所启发或帮助,您能否将我的答案标记为accepted,谢谢~
标签: python django azure manage.py