簡體   English   中英

Python 部署到 Azure App Service 失敗無報錯

[英]Python deployment to Azure App Service fails without error

我有一個 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 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

我不知道運行了什么或如何找到錯誤所在的 go。 我能夠成功地部署示例項目 該項目約為140MB。

通常,故障排除的第一步是使用應用服務診斷:

在您的 web 應用程序的 Azure 門戶上,select 從左側菜單診斷和解決問題 Select可用性和性能 檢查應用程序日志、容器崩潰容器問題選項中的信息,其中會出現最常見的問題。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM