Python部署到Azure应用程序服务失败,没有出现错误



我有一个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 112n   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 log deployment show -n mechanics-of-search-api -g mechanics-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

我不知道运行了什么,也不知道如何找到错误所在。我成功地部署了示例项目。该项目约为140MB。

通常,故障排除的第一步是使用应用程序服务诊断:

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

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

其他注意事项

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

最新更新