I am trying to deploy a simple flask application to an Azure App Service container, however when deploying from github repository I am getting an error saying ModuleNotFoundError: No module named 'requests'
.
I have the requirements.txt file in the project populated using pip freeze > requirements.txt.
requirements.txt
bcrypt==4.0.1
cffi==1.15.1
click==8.1.3
colorama==0.4.6
cryptography==38.0.4
dnspython==2.2.1
Flask==2.2.2
Flask-Cors==3.0.10
itsdangerous==2.1.2
Jinja2==3.1.2
jwt==1.3.1
MarkupSafe==2.1.1
pathlib==1.0.1
pycparser==2.21
pymongo==4.3.3
six==1.16.0
Werkzeug==2.2.2
Wheelhouse==0.1.4
My pipeline yml file:
name: Build and deploy Python app to Azure Web App - b00782310-com774
on:
push:
branches:
- main
workflow_dispatch:
env:
SCM_DO_BUILD_DURING_DEPLOYMENT: 1
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: '3.8'
# - 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: Upload artifact for deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-app
path: |
.
!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@v2
with:
name: python-app
path: .
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: 'b00782310-com774'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_AF561207AFB44DF1B5B6F54DFA612E98 }}
Any help would be appreciated, tried a lot of tips online but cannot get it working.
CodePudding user response:
Have you tried including 'requests' in your requirements:
...
pycparser==2.21
pymongo==4.3.3
requests == 2.28.1
six==1.16.0
Werkzeug==2.2.2
...
Or add it directly to your yml dependencies, i.e.
- name: Install dependencies
run: |
pip install -r requirements.txt
python -m pip install requests
This is pretty new to me too - but hopefully this helps.
There's some decent help in app-service msft github repo too