gpt4 book ai didi

Python 部署到 Azure 应用服务失败且没有错误

转载 作者:行者123 更新时间:2023-12-03 03:50:02 25 4
gpt4 key购买 nike

我有一个 Python 应用程序,可以通过 vscode 并使用 flask run 在本地运行,不会出现任何问题。

当我尝试以下命令将应用程序推送到 Azure 时,失败:

(.venv) C:\MOS>az webapp up --sku B1 --name mechanics-of-search-api --location "North Europe" -g "mechanics-of-search"
The webapp 'mechanics-of-search-api' doesn't exist
Creating AppServicePlan 'michaelryan998_asp_Linux_northeurope_0' ...
Creating webapp 'mechanics-of-search-api' ...
Configuring default logging for the app, if not already enabled
Creating zip with contents of dir C:\MOS ...
Getting scm site credentials for zip deployment
Starting zip deployment. This operation can take a while to complete ...
Deployment endpoint responded with status code 202
Configuring default logging for the app, if not already enabled
Zip deployment failed. {'id': '748e8415-1c27-484e-94e6-0855a5b6de60', 'status': 3, 'status_text': '', 'author_email': 'N/A', 'author': 'N/A', 'deployer': 'Push-Deployer', 'message': 'Created via a push deployment', 'progress': '', 'received_time': '2021-04-12T17:47:20.5128971Z', 'start_time': '2021-04-12T17:47:21.7678719Z', 'end_time': '2021-04-12T17:47:50.2735201Z', 'last_success_end_time': None, 'complete': True, 'active': False, 'is_temp': False, 'is_readonly': True, 'url': 'https://mechanics-of-search-api.scm.azurewebsites.net/api/deployments/latest', 'log_url': 'https://mechanics-of-search-api.scm.azurewebsites.net/api/deployments/latest/log', 'site_name': 'mechanics-of-search-api'}. Please run the command az webapp log deployment show -n mechanics-of-search-api -g mechanics-of-search

当我尝试打开 https://mechanics-of-search-api.scm.azurewebsites.net/api/deployments/latest/log 处的日志时:

{"ClassName":"System.IO.FileNotFoundException","Message":"No log found for 'latest'.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":"   at Kudu.Core.Deployment.DeploymentManager.GetLogEntries(String id) in /tmp/KuduLite/Kudu.Core/Deployment/DeploymentManager.cs:line 112\n   at Kudu.Services.Deployment.DeploymentController.GetLogEntry(String id) in /tmp/KuduLite/Kudu.Services/Deployment/DeploymentController.cs:line 432","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":null,"HResult":-2147024894,"Source":"Kudu.Core","WatsonBuckets":null,"FileNotFound_FileName":null,"FileNotFound_FusionLog":null}

如果我执行 az webapp logDeployment show -nmechanis-of-search-api -gmechanis-of-search

[
{
"details_url": null,
"id": "a8aa2668-bd08-4617-a48a-731ebd815823",
"log_time": "2021-04-12T17:47:20.6319438Z",
"message": "Updating submodules.",
"type": 0
},
{
"details_url": null,
"id": "2bebee7b-51a9-4f29-8c23-9ccefbc1c17d",
"log_time": "2021-04-12T17:47:21.7065948Z",
"message": "Preparing deployment for commit id '748e8415-1'.",
"type": 0
},
{
"details_url": null,
"id": "9cd7ebd1-6aea-4feb-ad90-7461644968dc",
"log_time": "2021-04-12T17:47:21.9512376Z",
"message": "Repository path is /tmp/zipdeploy/extracted",
"type": 0
},
{
"details_url": "https://mechanics-of-search-api.scm.azurewebsites.net/api/deployments/748e8415-1c27-484e-94e6-0855a5b6de60/log/69a4b157-8ddc-492a-ba84-d000bbb545dc",
"id": "69a4b157-8ddc-492a-ba84-d000bbb545dc",
"log_time": "2021-04-12T17:47:22.0239278Z",
"message": "Running oryx build...",
"type": 2
}
]

这是我的requirements.txt 文件:

app==1.0 #Locally defined modules in the project
beautifulsoup4==4.9.3
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
Flask==1.1.2
idna==2.10
itsdangerous==1.1.0
Jinja2==2.11.3
joblib==1.0.1
MarkupSafe==1.1.1
nltk==3.6.1
numpy==1.20.2
progressbar2==3.53.1
python-utils==2.5.6
regex==2021.4.4
requests==2.25.1
six==1.15.0
soupsieve==2.2.1
tqdm==4.60.0
urllib3==1.26.4
Werkzeug==1.0.1
wikipedia==1.4.0

我不知道运行了什么或如何查找错误所在。我成功部署了 sample project 。该项目大约140MB。

最佳答案

一般来说,故障排除的第一步是使用应用服务诊断:

在 Web 应用的 Azure 门户上,从左侧菜单中选择诊断并解决问题。选择可用性和性能。检查应用程序日志、容器崩溃容器问题选项中的信息,其中会出现最常见的问题。

https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#troubleshooting

其他注意事项

  1. 确保您位于正确的文件夹中。 az webapp up 应该运行从包含您的代码的本地文件夹。最常见的错误正在父目录中运行命令。
  2. 确认您的项目结构符合“自动下面的“运行时检测逻辑”部分。
  3. 还有问题吗?创造我们的存储库中的一个问题: https://github.com/Azure/app-service-linux-docs/issues

关于Python 部署到 Azure 应用服务失败且没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67063489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com