Deploying a Python App to Azure App Service with Github Actions
Автор: Emrah KAYA
Загружено: 2025-08-01
Просмотров: 10
Описание:
Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram: / ky.emrah
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!Deploying a Python App to Azure App Service with Github Actions
I'm encountering an issue with deploying my Python web application to Azure App Service using CI/CD with GitHub Actions. The goal is for the application to connect to an Azure SQL backend for querying, but the deployment is not working as expected.
I am attempting to deploy it from my GitHub directory via Actions, and I have added a secret secrets.AZURE_WEBAPP_PUBLISH_PROFILE with the content from the Azure App Service publish profile file.
secrets.AZURE_WEBAPP_PUBLISH_PROFILE
The structure of my GitHub repository is as follows:
/python-app$
.
├── app
│ ├── app.py
│ ├── requirements.txt
│ ├── static
│ │ └── styles.css
│ └── templates
│ ├── index.html
│ └── welcome.html
├── terraform-infra
/python-app$
.
├── app
│ ├── app.py
│ ├── requirements.txt
│ ├── static
│ │ └── styles.css
│ └── templates
│ ├── index.html
│ └── welcome.html
├── terraform-infra
Here is the pipeline I have created
name: Build and Deploy Python App to Azure Web App
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: Install unixodbc
run: sudo apt-get install -y unixodbc
name: Create and activate virtual environment
run: |
python -m venv venv
source venv/bin/activate
name: Install dependencies
run: pip install -r app/requirements.txt
name: Compress artifact for deployment
run: zip release.zip ./app/* -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 }}
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
mv app/* .
name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'python-app-mario'
slot-name: 'production'
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
name: Build and Deploy Python App to Azure Web App
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: Install unixodbc
run: sudo apt-get install -y unixodbc
name: Create and activate virtual environment
run: |
python -m venv venv
source venv/bin/activate
name: Install dependencies
run: pip install -r app/requirements.txt
name: Compress artifact for deployment
run: zip release.zip ./app/* -r
name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v4
with:
name: python-app
path: |
Source of the question:
https://stackoverflow.com/questions/7...
Question and source license information:
https://meta.stackexchange.com/help/l...
https://stackoverflow.com/
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: