0

Context : I have a GitHub Action that deploys an Azure Function. It's crashing every time someone is pushing to 'dev' branch. The only manual "workaround" I found that works is the following;

  1. Go to Azure's Function App > Configuration > Application Settings
  2. Remove WEBSITE_RUN_FROM_PACKAGE=1 configuration
  3. Rerun all jobs on GitHub Actions (succeeds like this)
  4. Add WEBSITE_RUN_FROM_PACKAGE=1 configuration again, otherwise I'm stuck in a login loop using msal (NodeJS)

Note that I have two environments. One is 'dev' and the other one is 'prod'.

GitHub Action failed job description :

Run Azure/[email protected]
  with:
    app-name: myapi
    package: ./functionsApi
    publish-profile: ***
    slot-name: dev
    scm-do-build-during-deployment: true
    enable-oryx-build: false
    respect-pom-xml: false
    respect-funcignore: false
  env:
    AZURE_FUNCTIONAPP_NAME: myapi
    AZURE_FUNCTIONAPP_SLOT: dev
    AZURE_FUNCTIONAPP_PACKAGE_PATH: ./functionsApi
    AZURE_FUNCTIONAPP_PUBLISH_PROFILE: ***
    NODE_VERSION: 16.x
Successfully parsed SCM credential from old publish-profile format.
Using SCM credential for authentication, GitHub Action will not perform resource validation.
Sucessfully acquired app settings from function app (with SCM credential)!
Will archive ./functionsApi into D:\a\_temp\temp_web_package_5053591759469989.zip as function app content
Will use Kudu https://<scmsite>/api/zipdeploy to deploy since publish-profile is detected.
Setting SCM_DO_BUILD_DURING_DEPLOYMENT in Kudu container to true
Update using Client.updateAppSettingViaKudu
Response with status code 204
App setting SCM_DO_BUILD_DURING_DEPLOYMENT propagated to Kudu container
Setting ENABLE_ORYX_BUILD in Kudu container to false
Update using Client.updateAppSettingViaKudu
Response with status code 204
App setting ENABLE_ORYX_BUILD propagated to Kudu container
Package deployment using ZIP Deploy initiated.
Error: Failed to deploy web package to App Service.
Successfully updated deployment History at https://REMOVEDpi-dev.scm.azurewebsites.net/api/deployments/d3799f4XXX933eaa14f3663f3ebdfa67f9732d7b175b1690836786357
Error: Execution Exception (state: PublishContent) (step: Invocation)
Error:   When request Azure resource at PublishContent, zipDeploy : Failed to use D:\a\_temp\temp_web_package_5053591759469989.zip as ZipDeploy content
Error:     Failed to deploy web package to App Service.
Internal Server Error (CODE: 500)
Error:       Error: Failed to deploy web package to App Service.
Internal Server Error (CODE: 500)
    at Kudu.<anonymous> (D:\a\_actions\Azure\functions-action\v1.3.2\node_modules\azure-actions-appservice-rest\Kudu\azure-app-kudu-service.js:175:23)
    at Generator.next (<anonymous>)
    at fulfilled (D:\a\_actions\Azure\functions-action\v1.3.2\node_modules\azure-actions-appservice-rest\Kudu\azure-app-kudu-service.js:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error: Deployment Failed!

myapp/.github/workflows/dev.node.js-functionapp-on-azure.yml :

name: (DEV) Deploy Node.js project to Azure Function App

on:
  push:
    branches:
      - dev

env:
  AZURE_FUNCTIONAPP_NAME: myapp
  AZURE_FUNCTIONAPP_SLOT: dev
  AZURE_FUNCTIONAPP_PACKAGE_PATH: "./functionsApi"
  AZURE_FUNCTIONAPP_PUBLISH_PROFILE: "${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE_DEV }}"
  NODE_VERSION: "16.x" # set this to the node version to use (supports 8.x, 10.x, 12.x)

jobs:
  build-and-deploy:
    runs-on: windows-latest
    environment: dev
    steps:
      - name: "Checkout GitHub Action"
        uses: actions/checkout@master

      - name: "Log env variables"
        run: |
          echo "AZURE_FUNCTIONAPP_NAME: ${{ env.AZURE_FUNCTIONAPP_NAME }}"
          echo "AZURE_FUNCTIONAPP_SLOT: ${{ env.AZURE_FUNCTIONAPP_SLOT }}"
          echo "GITHUB_WORKSPACE: ${{ github.workspace }}"

      - name: Setup Node ${{ env.NODE_VERSION }} Environment
        uses: actions/setup-node@v1
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: "Resolve Project Dependencies Using Npm"
        shell: pwsh
        run: |
          pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
          npm install --force
          npm run build --if-present
          popd

      - name: "Run Azure Functions Action"
        uses: Azure/[email protected]
        id: fa
        with:
          app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
          package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
          publish-profile: ${{ env.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}
          slot-name: ${{ env.AZURE_FUNCTIONAPP_SLOT }}
          scm-do-build-during-deployment: true
          enable-oryx-build: false

# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples

Function App Configuration Application Settings

2
  • Could you please share the GitHub Repo ? Commented Aug 4, 2023 at 7:06
  • I cannot since it's private. I can provide any files after filtering some secrets Commented Aug 7, 2023 at 19:31

1 Answer 1

0

I tried deploying Azure Function Http Trigger from Master branch then from Dev branch using Github actions and it was successfull, In both the branches, Refer below:-

Master Branch:-

enter image description here

My repository:-

function.json and index.js are inside HttpTrigger1 folder and rest other files are outside it.

enter image description here

My github action workflow:-

name: Build and deploy Node.js project to Azure Function App - siliconfunchttp5

on:
  push:
    branches:
      - master
  workflow_dispatch:

env:
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
  NODE_VERSION: '18.x' # set this to the node version to use (supports 8.x, 10.x, 12.x)

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout GitHub Action'
        uses: actions/checkout@v2

      - name: Setup Node ${{ env.NODE_VERSION }} Environment
        uses: actions/setup-node@v1
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: 'Resolve Project Dependencies Using Npm'
        shell: bash
        run: |
          pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
          npm install
          npm run build --if-present
          npm run test --if-present
          popd
      - name: 'Run Azure Functions Action'
        uses: Azure/functions-action@v1
        id: fa
        with:
          app-name: 'siliconfunchttp5'
          slot-name: 'Production'
          package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_xxxxxxxxB474E9AAxxx }}

enter image description here

My dev branch:-

enter image description here

enter image description here

My github action workflow:-

name: Build and deploy Node.js project to Azure Function App - siliconfunchttp5

on:
  push:
    branches:
      - dev
  workflow_dispatch:

env:
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
  NODE_VERSION: '18.x' # set this to the node version to use (supports 8.x, 10.x, 12.x)

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout GitHub Action'
        uses: actions/checkout@v2

      - name: Setup Node ${{ env.NODE_VERSION }} Environment
        uses: actions/setup-node@v1
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: 'Resolve Project Dependencies Using Npm'
        shell: bash
        run: |
          pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
          npm install
          npm run build --if-present
          npm run test --if-present
          popd
      - name: 'Run Azure Functions Action'
        uses: Azure/functions-action@v1
        id: fa
        with:
          app-name: 'siliconfunchttp5'
          slot-name: 'Production'
          package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_DBCADBE233F1419E80B62A174A205A96 }}

enter image description here

enter image description here

Note- I created my Function app in Linux OS.

  • In order to resolve your error, Make sure your function trigger folder is in correct format like above in the dev branch and no folder or packages are missing and both the branches are in sync. The github action workflow will automatically initiate zip deployment and add the function app settings if necessary.

  • Clear your previous github action workflows and delete the artifacts and github action cache and re run the Function app workflow again via Azure Portal > Deployment Center and connecting to your Github account and the Function branch.

Sign up to request clarification or add additional context in comments.

Comments

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.