Deploying Python Applications using Github Actions

3 minute read | By Keegan D'Souza

In this blog post we will cover Github Actions Deployment to a Python App Service.

By default when you configure your workflow file using the Deployment Center the build happens still happens using the app service build system (oryx).

The goal of this blog, is to demonstration how to switch the build process to only occur on Github Actions.

You can follow along by forking the following Azure Sample Repository: Azure-Samples/python-docs-hello-world(A simple python application for docs (

Set Up Initial Deployment:

  1. Sync your Github Repository to the app service deployment center.

    Deployment Center

    After doing so you will see the app service will have the below app setting enabled automatically.


    This will enable the app service build system oryx, however for the purpose of this article we would like to disable this as we want the build to only occur on Github Actions.

  2. Disable the oryx build system by changing this to 0 or false and save your changes.


    App Settings

Modify Workflow file

  1. Navigate to your Github Actions Repository and open your generated github actions .yml file. It will be located under .github/workflows/{branch_name}_{app service name}.yml.

  2. Modify the following sections in your workflow file.

    Rename the virtual environment to antenv


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


     - name: Create and start virtual environment
         run: |
           python -m venv antenv
           source antenv/bin/activate
    Explanation Currently the default value of the virtual environment the app service looks for is named antenv, we can view this by navigating to the app service startup script under /opt/startup/
         echo 'export VIRTUALENVIRONMENT_PATH="/home/site/wwwroot/antenv"' >> ~/.bashrc
         echo '. antenv/bin/activate' >> ~/.bashrc
         PYTHON_VERSION=$(python -c "import sys; print(str(sys.version_info.major) + '.' + str(sys.version_info.minor))")
         echo Using packages from virtual environment 'antenv' located at '/home/site/wwwroot/antenv'.
         export PYTHONPATH=$PYTHONPATH:"/home/site/wwwroot/antenv/lib/python$PYTHON_VERSION/site-packages"
         echo "Updated PYTHONPATH to '$PYTHONPATH'"

    Include the virtual environment in the archive.


     - name: Upload artifact for deployment jobs
         uses: actions/upload-artifact@v2
           name: python-app
           path: |


     - name: Upload artifact for deployment jobs
         uses: actions/upload-artifact@v2
           name: python-app
           path: .
    Explanation Since the build is not occuring on the app service side we need to include the created virtual enviornment in the .zip archive. Previously this was being exculding and the virtual environment was being built by the app service build system again. You can validate that your virtual environment is included inside the article by downloading it and extracting the content to see if the virtual environment was included.

Commit your changes and test.

  1. Commit your changes and monitor your deployment.
  2. Your app service should be able to startup successfully using the virtual environment created on Github Actions.

    App Settings

    Depending on your project structure you may need to modify your startup command.

    More information here: Configure a Linux Python app for Azure App Service


  • Simplifies the deployment process by removing the app service oryx build process. By default the pip install is running twice, once on Github Actions and once during the oryx build process.
  • Allows users to take of Advantage of Github Actions Features, such as a build cache to possibly improve deployment times.

    More information here: Caching dependencies to speed up workflows