我正在进行 GitHub 操作,一切看起来都很成功,但应用程序似乎尚未部署。
yaml:
name: Build and deploy Python app to Azure Web App - fast-api-port
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: pip install -r requirements.txt
# Optional: Add step to run tests here (PyTest, Django test suites, etc.)
- name: Zip artifact for deployment
run: zip release.zip ./* -r
- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v4
with:
name: python-app
path: |
release.zip
!venv/
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: python-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_7C6D249DE594426EBD4725CC0D066145 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_6399B578ADAF41E095CA377A465B8BB1 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_527AF2EA4A6A4A8BAC99ECB57B6CE6AB }}
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'fast-api-port'
slot-name: 'Production'
日志显示 0 个错误和 0 个警告。但是,当我进入文件管理器时,我找不到任何上传的文件,这可能就是我无法运行我的应用程序的原因:
我是否遗漏了某些内容或者我看不到这些文件?我使用 FTP 连接进行测试只是为了确定,但任何地方都没有 .py 文件?
正如我在评论中提到的,将 python 应用程序部署到 Azure Web Apps (Linux) 时,文件在部署过程中被捆绑到
output.tar.gz
中。
此存档包含在 Azure 应用服务上运行应用程序的所有文件和依赖项,例如虚拟环境、requirements.txt。
我们可以通过下载
output.tar.gz
文件夹来检查内容。
在 Kudu 控制台中,您可以在文件管理器 -> site/wwwroot 下找到
output.tar.gz
文件。