Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python application fails when deployed from GitHub Actions #2582

Open
benheriford opened this issue Feb 19, 2025 · 6 comments
Open

Python application fails when deployed from GitHub Actions #2582

benheriford opened this issue Feb 19, 2025 · 6 comments

Comments

@benheriford
Copy link

When deploying a basic function app from GitHub actions to azure on any plan, adding any import other than the default import logging and import azure.functions as func (for example from azure.cosmos import CosmosClient) the application will not show the function in portal, as well calling the function returns either 500 or 404 and the host errors with "module not found". I was able to identify the underlying cause for this. The yaml that is created when you link the application to GitHub from the Azure portal seems to have a slight issue.

 - name: Create and start virtual environment

    run: |

      python -m venv venv

      source venv/bin/activate


  - name: Install dependencies

    run: pip install -r requirements.txt

the above is the yaml that is generated in portal, however, the venv does not seem to persist between steps and you have to modify the install dependencies step as shown below in order for the requirements.txt file to actually install.

  • name: Create and start virtual environment
    run: |
    python -m venv venv
    source venv/bin/activate

    • name: Install dependencies
      run: |
      source venv/bin/activate
      pip install -r requirements.txt
@edwinjongsma
Copy link

We are using Azure Functions with Python/Linux and a few weeks ago our CI/CD with GitHub started generating errors whereas it was working seamlessly before. The deployments were success but there were errors regardless. The deployment logfiles did not identify the root cause.

This seems to be the root cause of those errors thanks for identifying Ben. I will implement this workaround in our YML and hope this gets fixed towards the future.

@JAdluri JAdluri self-assigned this Feb 26, 2025
@JAdluri
Copy link

JAdluri commented Feb 26, 2025

Hello @benheriford please let me know if the issue still exists.

@benheriford
Copy link
Author

Hey @JAdluri it is still on going, for one application, it does seem to have resolved the issue, but strangely, another (identical) application seems to not be fixed by this

@benheriford
Copy link
Author

In further testing we as well found that adding the following to the YML was able to resolve it for the second app as well, despite enable_oryx_build being set to 1 in the environment variables.

     scm-do-build-during-deployment: true
     enable-oryx-build: true

@JAdluri
Copy link

JAdluri commented Feb 27, 2025

With the above resolution was it able to fix the issue for any other identical application.

@benheriford
Copy link
Author

@JAdluri Yes, I have reproduced the issue a couple more times, it simply seems that the generated workflow from Azure is causing this issue due to missing a couple of things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants