azure 应用程序服务令人头痛...无法部署应用程序

问题描述 投票:0回答:1

我什至不知道从哪里开始。已经坚持这个问题好几个星期了。天蓝色支持没有帮助

尝试通过

部署我的网络应用程序
az webapp up --runtime PYTHON:3.9 --sku B1 --logs 

按照教程执行命令。

尝试了很多事情和故障排除步骤都不起作用,但降级到 python 3.9 似乎解决了这个问题。关闭网络应用程序,因为只是想测试部署

你瞧,是时候再次部署了,即使是 3.9 也无法正常工作。与之前的错误非常相似。

一切看起来都很好,直到您访问该网站并显示默认页面。

Hey, Python developers!

Your app service is up and running.
Time to take the next step and deploy your code.

拜托,我被困住了。我不知道该怎么做。日志或多或少看起来不错。唯一的例外可能是这一行:

**2024-07-20T05:59:44.2790642Z No framework detected; using default app from /opt/defaultsite**

来自 docker.log 文件的完整日志:

2024-07-20T05:55:00.3902714Z    _____                               
2024-07-20T05:55:00.3986130Z   /  _  \ __________ _________   ____  
2024-07-20T05:55:00.3986446Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
2024-07-20T05:55:00.3986509Z /    |    \/    /|  |  /|  | \/\  ___/ 
2024-07-20T05:55:00.3986564Z \____|__  /_____ \____/ |__|    \___  >
2024-07-20T05:55:00.3986623Z         \/      \/                  \/ 
2024-07-20T05:55:00.3986678Z A P P   S E R V I C E   O N   L I N U X
2024-07-20T05:55:00.3986739Z 
2024-07-20T05:55:00.3986817Z Documentation: http://aka.ms/webapp-linux
2024-07-20T05:55:00.3986873Z Python 3.9.19
2024-07-20T05:55:00.3986927Z Note: Any data outside '/home' is not persisted
2024-07-20T05:55:03.8214747Z Starting OpenBSD Secure Shell server: sshd.
2024-07-20T05:55:03.9381273Z WEBSITES_INCLUDE_CLOUD_CERTS is not set to true.
2024-07-20T05:55:04.2147956Z App Command Line not configured, will attempt auto-detect
2024-07-20T05:55:04.5881884Z Starting periodic command scheduler: cron.
2024-07-20T05:55:04.5894244Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite
2024-07-20T05:55:04.6707489Z Could not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2024-07-20T05:55:04.6793501Z Could not find operation ID in manifest. Generating an operation id...
2024-07-20T05:55:04.6794124Z Build Operation ID: 0b109b87-79d7-48d6-b574-02224ca2189f
2024-07-20T05:55:05.1858753Z Oryx Version: 0.2.20240619.2, Commit: cf006407a02b225f59dccd677986973c7889aa50, ReleaseTagName: 20240619.2
2024-07-20T05:55:05.2140942Z No framework detected; using default app from /opt/defaultsite
2024-07-20T05:55:05.2236371Z Generating `gunicorn` command for 'application:app'
2024-07-20T05:55:05.2517486Z Writing output script to '/opt/startup/startup.sh'
2024-07-20T05:55:05.4037423Z WARNING: Could not find virtual environment directory /home/site/wwwroot/antenv.
2024-07-20T05:55:05.4038188Z WARNING: Could not find package directory /home/site/wwwroot/__oryx_packages__.
2024-07-20T05:55:14.2190016Z [2024-07-20 05:55:14 +0000] [72] [INFO] Starting gunicorn 22.0.0
2024-07-20T05:55:14.2989377Z [2024-07-20 05:55:14 +0000] [72] [INFO] Listening at: http://0.0.0.0:8000 (72)
2024-07-20T05:55:14.3000537Z [2024-07-20 05:55:14 +0000] [72] [INFO] Using worker: sync
2024-07-20T05:55:14.3510534Z [2024-07-20 05:55:14 +0000] [85] [INFO] Booting worker with pid: 85
2024-07-20T05:55:15.2720796Z 169.254.130.1 - - [20/Jul/2024:05:55:15 +0000] "GET /robots933456.txt HTTP/1.1" 404 207 "-" "HealthCheck/1.0"
2024-07-20T05:55:17.8317395Z 169.254.130.1 - - [20/Jul/2024:05:55:17 +0000] "GET / HTTP/1.1" 200 0 "-" "vscode-azureappservice/0.25.2 core-rest-pipeline/1.11.0 Node/v20.9.0 OS/(x64-Windows_NT-10.0.22631)"
2024-07-20T05:55:17.8318606Z 169.254.130.1 - - [20/Jul/2024:05:55:17 +0000] "GET / HTTP/1.1" 200 0 "-" "ReadyForRequest/1.0 (LocalCache)"
2024-07-20T05:55:18.1029493Z 169.254.130.1 - - [20/Jul/2024:05:55:18 +0000] "GET / HTTP/1.1" 200 0 "-" "ReadyForRequest/1.0 (AppInit)"
2024-07-20T05:59:13.3801927Z    _____                               
2024-07-20T05:59:13.3830788Z   /  _  \ __________ _________   ____  
2024-07-20T05:59:13.3830958Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
2024-07-20T05:59:13.3831009Z /    |    \/    /|  |  /|  | \/\  ___/ 
2024-07-20T05:59:13.3831055Z \____|__  /_____ \____/ |__|    \___  >
2024-07-20T05:59:13.3831101Z         \/      \/                  \/ 
2024-07-20T05:59:13.3831177Z A P P   S E R V I C E   O N   L I N U X
2024-07-20T05:59:13.3831231Z 
2024-07-20T05:59:13.3831279Z Documentation: http://aka.ms/webapp-linux
2024-07-20T05:59:13.3831412Z Python 3.9.19
2024-07-20T05:59:13.4094526Z Note: Any data outside '/home' is not persisted
2024-07-20T05:59:13.4100953Z Starting OpenBSD Secure Shell server: sshd.
2024-07-20T05:59:13.4103417Z WEBSITES_INCLUDE_CLOUD_CERTS is not set to true.
2024-07-20T05:59:13.4104380Z App Command Line not configured, will attempt auto-detect
2024-07-20T05:59:13.6625701Z Starting periodic command scheduler: cron.
2024-07-20T05:59:13.6708328Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite
2024-07-20T05:59:13.7244425Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2024-07-20T05:59:13.7279268Z Build Operation ID: b17556e5486e42ab
2024-07-20T05:59:13.7290837Z Oryx Version: 0.2.20240619.2, Commit: cf006407a02b225f59dccd677986973c7889aa50, ReleaseTagName: 20240619.2
2024-07-20T05:59:13.7292985Z Output is compressed. Extracting it...
2024-07-20T05:59:13.7310566Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8dca87ff5223cb1'...
2024-07-20T05:59:44.2576475Z App path is set to '/tmp/8dca87ff5223cb1'
- **2024-07-20T05:59:44.2790642Z No framework detected; using default app from /opt/defaultsite**
2024-07-20T05:59:44.2802269Z Generating `gunicorn` command for 'application:app'
2024-07-20T05:59:44.3170940Z Writing output script to '/opt/startup/startup.sh'
2024-07-20T05:59:52.8680747Z Using packages from virtual environment antenv located at /tmp/8dca87ff5223cb1/antenv.
2024-07-20T05:59:52.8751736Z Updated PYTHONPATH to '/agents/python:/opt/startup/app_logs:/tmp/8dca87ff5223cb1/antenv/lib/python3.9/site-packages'
2024-07-20T05:59:56.4825254Z [2024-07-20 05:59:56 +0000] [84] [INFO] Starting gunicorn 22.0.0
2024-07-20T05:59:56.5937341Z [2024-07-20 05:59:56 +0000] [84] [INFO] Listening at: http://0.0.0.0:8000 (84)
2024-07-20T05:59:56.5938220Z [2024-07-20 05:59:56 +0000] [84] [INFO] Using worker: sync
2024-07-20T05:59:56.6264592Z [2024-07-20 05:59:56 +0000] [97] [INFO] Booting worker with pid: 97
2024-07-20T05:59:56.6519476Z 169.254.130.1 - - [20/Jul/2024:05:59:56 +0000] "GET / HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0"
2024-07-20T05:59:57.0656262Z 169.254.130.1 - - [20/Jul/2024:05:59:57 +0000] "GET /robots933456.txt HTTP/1.1" 404 207 "-" "HealthCheck/1.0"
2024-07-20T05:59:57.7421541Z [2024-07-20 05:59:57 +0000] [85] [INFO] Worker exiting (pid: 85)
2024-07-20T05:59:57.7934766Z [2024-07-20 05:59:57 +0000] [72] [INFO] Handling signal: term`

在我的settings.py中,我设置:

ALLOWED_HOSTS = ['*']`

仅用于测试目的。所以我知道这个问题不可能来自于此。 最后还有这个:

STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATIC_ROOT = BASE_DIR / 'staticfiles'

The SCM_DO_BUILD_DURING_DEPLOYMENT
也设置为 true。

我什至不知道从哪里开始。我不是一个真正的 DevOps 人。

还有其他事情我有兴趣讨论(例如,一位 azure 支持工程师告诉我 python 4.1~ 和带有 azure 应用程序服务的最新 django 有一个错误,但那是另一个话题)

现在我只想启动这个,即使没有人知道问题是什么,我到底应该查明它可能来自哪里? Azure 表示最近部署成功。显然不是。

如果有帮助的话我可以使用 webssh。

我从我的电脑上的一个文件夹部署它,该文件夹链接到 github,但不是通过 Ci/cd 管道从 github 链接。我认为本地 git 是这个词

-更改 python 版本 -更新requirements.txt文件 - 尝试一些设置 -天蓝色支持`

django azure azure-web-app-service
1个回答
0
投票

我从 MS 文档克隆了 GitHub 存储库,以创建 Django Web 应用程序并将其部署到 Azure 应用程序服务。

出于部署目的,我运行以下命令在项目中创建虚拟目录(venv)。

py -m venv .venv
.venv\scripts\activate

确保requirements.txt 文件包含所需的包。

需求.txt:

Django
whitenoise

我运行以下命令将 django Web 应用程序部署到 Azure 应用程序服务。

az webapp up --runtime PYTHON:3.9 --sku B1 --location eastus2 --logs

我已成功将 django 应用程序部署到 Azure Web 应用程序,如下所示。

enter image description here

Azure Web 应用程序输出enter image description here

如果您仍然面临部署问题,请使用 Visual Studio Azure 扩展将您的应用程序部署到 Azure。

  • 首先在门户中创建一个 Azure Web 应用程序,如下所示。

enter image description here

  • 选择 Azure 扩展并登录到您的订阅,然后选择您的 Web 应用程序,右键单击它 -> 部署到 Web 应用程序 -> 项目文件。

enter image description here

成功部署后,如果您看到示例页面或错误页面,请使用以下命令作为 Azure 应用服务的配置部分中的启动命令。

gunicorn --bind=0.0.0.0 --timeout 600 <yourprojectnameContainswsgifile>.wsgi

enter image description here

Azure 输出

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.