0

I have a GitHub repo that contains a client folder for the front-end and a server folder for the back-end at the root of the repo. We are deploying each of these two folders to their own azure web app within the same app service plan. I have a github action yaml file that deploys the contents of the server folder to the web app, but we would like to use absolute imports in our python backend (pylint and some other stuff seems to like that), so all of our imports look like from server.module import something which fails on azure because there is no server folder and the module folder is placed inside of whatever the default root folder on the web app server is. If we change that import to from module import something everything works.

What would be the best way to deploy this python app to the web app while still being able to use absolute imports? I'm assuming if we could throw everything inside of a server folder and change the startup command to reflect the new path of the app.py everything would work but getting the action to do this has proven difficult has been an issue. This is how my github action yaml currently looks:


on:
  push:
    branches:
      - beta
    paths:
      - 'server/**'
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python version
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Create and start virtual environment
        run: |
          python -m venv venv
          source venv/bin/activate
        working-directory: ./server
      
      - name: Install dependencies
        run: pip install -r requirements.txt
        working-directory: ./server
        
      # Optional: Add step to run tests here (PyTest, Django test suites, etc.)

      - name: Upload artifact for deployment jobs
        uses: actions/upload-artifact@v4
        with:
          name: python-app
          path: |
            ./server
            !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@v4
        with:
          name: python-app
          path: ./server
      - name: Deploy web App using GH Action azure/webapps-deploy
        uses: azure/webapps-deploy@v3
        with:
          app-name: <our_app_name>
          slot-name: 'production'
          publish-profile: ${{ secrets.BACKEND_PUBLISH_PROFILE }}
          package: ./server```
7
  • Did you get any error? Commented Oct 11, 2024 at 18:53
  • we're currently using the from module import something import pattern so everything is running fine. if we do the from server.module import something import pattern we get the server module not found import error because the server folder doesn't exist Commented Oct 11, 2024 at 18:57
  • So you want to deploy server and client apps to two different azure web apps from single GitHub repository. Commented Oct 12, 2024 at 3:48
  • If possible, share your GitHub repository? Commented Oct 12, 2024 at 3:49
  • Yes we are deploying two separate web apps from the same repository. both web apps are under the same app registration. Unfortunately it is a private repo so cannot share it. The repo structure has a client and a server folder at the root level of the repo, and the server folder is what we are trying to deploy while using absolute imports. Commented Oct 16, 2024 at 17:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.