我们在使用 Az CLI 将 python 应用程序部署到应用服务时遇到问题。您知道问题根源吗?
这是我们使用的命令。我们在 ubuntu 虚拟机上执行它。
az webapp up -n $WEB_APP_NAME -l "westeurope" -g $RESOURCE_GROUP_NAME --sku B1
这是我们遇到的错误。我们不明白:
Zip deployment failed. {'id': '200a84e1e024461ca2ef18edd8c3f607', 'status': 3, 'status_text': '', 'author_email': 'N/A', 'author': 'N/A', 'deployer': 'Push-Deployer', 'message': 'Created via a push deployment', 'progress': '', 'received_time': '2021-06-22T15:49:57.8395052Z', 'start_time': '2021-06-22T15:49:59.5399261Z', 'end_time': '2021-06-22T15:50:13.4118115Z', 'last_success_end_time': None, 'complete': True, 'active': False, 'is_temp': False, 'is_readonly': True, 'url': 'https://test-surveillance-api-2.scm.azurewebsites.net/api/deployments/latest', 'log_url': 'https://test-surveillance-api-2.scm.azurewebsites.net/api/deployments/latest/log', 'site_name': 'test-surveillance-api-2'}. Please run the command az webapp log deployment show -n test-surveillance-api-2 -g azr-rg-bpceit-bpcesa-d2i2`
这里是完整部署日志的链接。在这些日志中,我看到以下错误。他们不清楚哈哈。
knack.util.CLIError: Zip deployment failed. {'id': '273909f740bd44de93111b0576d235f9', 'status': 3, 'status_text': '', 'author_email': 'N/A', 'author': 'N/A', 'deployer': 'Push-Deployer', 'message': 'Created via a push deployment', 'progress': '', 'received_time': '2021-06-22T16:11:12.3912894Z', 'start_time': '2021-06-22T16:11:13.5603203Z', 'end_time': '2021-06-22T16:11:23.3248561Z', 'last_success_end_time': None, 'complete': True, 'active': False, 'is_temp': False, 'is_readonly': True, 'url': 'https://test-surveillance-api-2.scm.azurewebsites.net/api/deployments/latest', 'log_url': 'https://test-surveillance-api-2.scm.azurewebsites.net/api/deployments/latest/log', 'site_name': 'test-surveillance-api-2'}. Please run the command az webapp log deployment show -n test-surveillance-api-2 -g azr-rg-bpceit-bpcesa-d2i2
cli.azure.cli.core.azclierror : Zip deployment failed. {'id': '273909f740bd44de93111b0576d235f9', 'status': 3, 'status_text': '', 'author_email': 'N/A', 'author': 'N/A', 'deployer': 'Push-Deployer', 'message': 'Created via a push deployment', 'progress': '', 'received_time': '2021-06-22T16:11:12.3912894Z', 'start_time': '2021-06-22T16:11:13.5603203Z', 'end_time': '2021-06-22T16:11:23.3248561Z', 'last_success_end_time': None, 'complete': True, 'active': False, 'is_temp': False, 'is_readonly': True, 'url': 'https://test-surveillance-api-2.scm.azurewebsites.net/api/deployments/latest', 'log_url': 'https://test-surveillance-api-2.scm.azurewebsites.net/api/deployments/latest/log', 'site_name': 'test-surveillance-api-2'}. Please run the command az webapp log deployment show -n test-surveillance-api-2 -g azr-rg-bpceit-bpcesa-d2i2
Zip deployment failed. {'id': '273909f740bd44de93111b0576d235f9', 'status': 3, 'status_text': '', 'author_email': 'N/A', 'author': 'N/A', 'deployer': 'Push-Deployer', 'message': 'Created via a push deployment', 'progress': '', 'received_time': '2021-06-22T16:11:12.3912894Z', 'start_time': '2021-06-22T16:11:13.5603203Z', 'end_time': '2021-06-22T16:11:23.3248561Z', 'last_success_end_time': None, 'complete': True, 'active': False, 'is_temp': False, 'is_readonly': True, 'url': 'https://test-surveillance-api-2.scm.azurewebsites.net/api/deployments/latest', 'log_url': 'https://test-surveillance-api-2.scm.azurewebsites.net/api/deployments/latest/log', 'site_name': 'test-surveillance-api-2'}. Please run the command az webapp log deployment show -n test-surveillance-api-2 -g azr-rg-bpceit-bpcesa-d2i2
有关环境的更多详细信息: 操作系统:Ubuntu 18.04.5 LTS Python版本:3.8.7
我解决了我的问题!!
做了一些研究后,我注意到问题出在requirements.txt和包含我的文件的存储库上。
因此,我将文件复制到另一个存储库中。我使用 python 虚拟环境 (./env/bin/python3) 的 python 生成了 requests.txt,而不是使用操作系统中安装的 python 生成的。
我不明白为什么这是问题所在。如果有人知道请告诉我。
祝你有美好的一天。
stages:
- build
- test
- deploy
default:
image: registry.hub.docker.com/library/python:3.10.14-alpine3.20
build-job:
stage: build
script:
- pip install pipenv
- pipenv install --deploy
- pipenv requirements > requirements.txt
artifacts:
paths:
- requirements.txt
deploy-to-dev:
stage: deploy
dependencies:
- build-job
environment: development
image: ubuntu:22.04
variables:
zipName: "my-app.zip"
script:
- apt-get update && apt-get install -y curl unzip zip lsb-release apt-transport-https gnupg
- curl -sL https://aka.ms/InstallAzureCLIDeb | bash
- zip -r ${zipName} .
- az login --service-principal -u xxxx -p xxxx --tenant xxxxx
- az webapp deploy --resource-group xxxxx --name xxxxx --src-path "${zipName}" --type zip
这是我的 gitlab-ci yaml。首先,从虚拟环境中导出需求。其次,制作zip并上传