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

Erfan Nariman 436 Reputation points

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
      - main
  PYTHON_VERSION: '3.8' # supports 3.6, 3.7, 3.8)
    runs-on: ubuntu-latest
    - name: 'Checkout GitHub Action'
      uses: actions/checkout@master
    - name: Setup Python ${<!-- -->{ env.PYTHON_VERSION }} Environment
      uses: actions/setup-python@v2
        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
        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/", 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/", 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- 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 App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,166 questions
0 comments No comments
{count} vote

3 answers

Sort by: Most helpful
  1. Dylan Accorti 6 Reputation points

    @EfranNariman-5893 - Did you get this resolved? I am running into the exact same issue and cannot get the deploy job to install my private package - though it does get installed to the artifact during build.

    1 person found this answer helpful.
    0 comments No comments

  2. Ryan Hill 26,771 Reputation points Microsoft Employee

    Hi @Erfan Nariman , 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 for more information on how to run those commands in your yml.


  3. Michael Anderson 1 Reputation point

    I had this problem, and my solution was to add a PRE_BUILD_COMMAND of git config --global url."https://PASTE ACCESS TOKEN HERE@github".insteadOf https://github - pop this in the app settings of your web app.

    0 comments No comments