Search code examples
azureazure-functionsgithub-actions

Python Azure function app github Package deployment using ZIP Deploy failed


Trying to deploy to Azure Function app with github actions The error I get:

error

My Config variables are set to:

  • ENABLE_ORYX_BUILD: false
  • SCM_DO_BUILD_DURING_DEPLOYMENT: false
  • WEBSITE_RUN_FROM_PACKAGE: 0

In the .yaml pipeline for functions-action set:

  • scm-do-build-during-deployment: false
  • enable-oryx-build: false

Solution

  • I tried deploying Python Function via Github Actions and it was successful, Refer below:-

    My Python Function V2 Github Repository For Python Function V1 refer my SO answer

    My github yaml pipeline:-

    name: Build and deploy Python project to Azure Function App - siliconfuncapp
    
    on:
      push:
        branches:
          - main
      workflow_dispatch:
    
    env:
      AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' 
      PYTHON_VERSION: '3.11' 
    
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout repository
            uses: actions/checkout@v4
    
          - name: Setup Python version
            uses: actions/setup-python@v1
            with:
              python-version: ${{ env.PYTHON_VERSION }}
    
          - name: Create and start virtual environment
            run: |
              python -m venv venv
              source venv/bin/activate
          - name: Install dependencies
            run: pip install -r requirements.txt
    
          
    
          - name: Zip artifact for deployment
            run: zip release.zip ./* -r
    
          - name: Upload artifact for deployment job
            uses: actions/upload-artifact@v3
            with:
              name: python-app
              path: |
                release.zip
                !venv/
      deploy:
        runs-on: ubuntu-latest
        needs: build
        environment:
          name: 'Production'
          url: ${{ steps.deploy-to-function.outputs.webapp-url }}
        permissions:
          id-token: write 
    
        steps:
          - name: Download artifact from build job
            uses: actions/download-artifact@v3
            with:
              name: python-app
    
          - name: Unzip artifact for deployment
            run: unzip release.zip     
            
          - name: Login to Azure
            uses: azure/login@v1
            with:
              client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_D0F74B57F2B045B5BC8B8494FB4C84C6 }}
              tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_2F1CE8D0C7B34809983E6F310DC66814 }}
              subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_35BE8BB9D9374F79ABFD06397E18EB36 }}
    
          - name: 'Deploy to Azure Functions'
            uses: Azure/functions-action@v1
            id: deploy-to-function
            with:
              app-name: 'siliconfuncapp'
              slot-name: 'Production'
              package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
              scm-do-build-during-deployment: true
              enable-oryx-build: true
    

    Output:-

    enter image description here

    enter image description here

    My Function App settings:-

    AzureWebJobsStorage:DefaultEndpointsProtocol=https;AccountName=siliconrg988a9c;AccountKey=xxxxxxx=;EndpointSuffix=core.windows.net
    ENABLE_ORYX_BUILD:1
    FUNCTIONS_EXTENSION_VERSION:~4
    FUNCTIONS_WORKER_RUNTIME:python
    SCM_DO_BUILD_DURING_DEPLOYMENT:1
    

    enter image description here

    Refer the Answers in this SO thread to get insights into your error.