question

ErfanNariman-5893 avatar image
0 Votes"
ErfanNariman-5893 asked ryanchill commented

Deploy runs succesful on GitHub actions, still ModuleNotFoundError on Azure Web App.

I use the given template for deploying to Azure Webapp through GH actions. Everything runs fine, but I still get ModuleNotFoundError when trying to access my website. My yaml:

name: My App
on:
  push:
    branches:
      - main
env:
  AZURE_WEBAPP_NAME: my-app
  AZURE_WEBAPP_PACKAGE_PATH: '.'
  PYTHON_VERSION: '3.8' # supports 3.6, 3.7, 3.8)
jobs:
  build-and-deploy-to-Azure:
    runs-on: ubuntu-latest
    steps:
    - name: 'Checkout GitHub Action'
      uses: actions/checkout@master
    - name: Setup Python ${<!-- -->{ env.PYTHON_VERSION }} Environment
      uses: actions/setup-python@v2
      with:
        python-version: ${<!-- -->{ env.PYTHON_VERSION }}
    - name: 'Install dependencies'
      run: |
        python -m pip install --upgrade pip
        git config --global url."https://${<!-- -->{ secrets.ACCESS_TOKEN }}@github".insteadOf https://github
        pip install -r requirements.txt
    - name: 'Deploy to Azure WebApp'
      uses: azure/webapps-deploy@v2
      with:
        app-name: ${<!-- -->{ env.AZURE_WEBAPP_NAME }}
        package: ${<!-- -->{ env.AZURE_WEBAPP_PACKAGE_PATH }}
        publish-profile: ${<!-- -->{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}


Note: ignore the characters after ${ these are not in my actual YAML.

But when I look in the log stream in our app, I see:

2021-02-15T16:51:47.899495269Z   File "/home/site/wwwroot/app.py", line 1, in <module>
2021-02-15T16:51:47.899499469Z     from sampling_app import app
2021-02-15T16:51:47.899503270Z   File "/home/site/wwwroot/sampling_app/__init__.py", line 2, in <module>
2021-02-15T16:51:47.899507570Z     from flask_login import LoginManager


But the module is definitely installed, when I look in the logs of GH actions:

Successfully installed Faker-6.1.1 Flask-1.1.2 Flask-Bcrypt-0.7.1 Flask-Bootstrap-3.3.7.1 Flask-Cors-3.0.10 Flask-Dropzone-1.5.4 Flask-Login-0.5.0 Flask-Mail-0.9.1 Flask-SQLAlchemy-2.4.4 Flask-WTF-0.14.3 Jinja2-2.11.3 MarkupSafe-1.1.1 SQLAlchemy-1.3.23 Six-1.15.0 WTForms-2.3.3 Werkzeug-1.0.1 bcrypt-3.2.0 blinker-1.4 cffi-1.14.5 click-7.1.2 dnspython-2.1.0 dominate-2.6.0 email-validator-1.1.2 et-xmlfile-1.0.1 idna-3.1 itsdangerous-1.1.0 jdcal-1.4.1 numpy-1.20.1 openpyxl-3.0.6 pandas-1.2.2 pycparser-2.20 pyodbc-4.0.30 python-dateutil-2.8.1 python-dotenv-0.15.0 pytz-2021.1 steekproef-0.0.1 text-unidecode-1.3 visitor-0.1.3 xlrd-2.0.1 xlsxwriter-1.3.7


What am I missing here? I hope I dont have to use azure/appservice-build@v2, because that way I am not sure how to install our pivate repo's, notice the line in our YAML:

git config --global url."https://${<!-- -->{ secrets.ACCESS_TOKEN }}@github".insteadOf https://github


We use an ACCES_TOKEN to access our private repos in our CD.



azure-webappsazure-webapps-content-deployment
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ryanchill avatar image
0 Votes"
ryanchill answered ryanchill commented

Hi @ErfanNariman-5893, when you check your docker logs, is your app running inside a virtual environment? If not, you may need to include that in your CI/CD pipeline. Check https://azure.github.io/AppService/2020/12/11/cicd-for-python-apps.html for more information on how to run those commands in your yml.

Regards,
Ryan


· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Ryan, thank you for the extensive article. Will try this asap and update you here.


Side note: this is pretty hard to find through the regular documentation. When I see a template CI/CD yml in the official docs, I assume it should work.

0 Votes 0 ·

Appreciate your feedback @ErfanNariman-5893 and completely agree. I will see about getting that addressed. Let me know if you have any issues.

Regards,
Ryan

0 Votes 0 ·

Hi @ErfanNariman-5893,

I saw your post on a separate Q&A question. You indicated updating your yaml to use 18.04 helped with your build. Are you still having issues with your actual deployment?

Regards,
Ryan


0 Votes 0 ·

Still didn't have time to fully test the blogpost. But I will 100% get back at you here when I tried. Thanks again for all the help!

1 Vote 1 ·
Show more comments