Azure / functions-action

Enable GitHub developers to deploy to Azure Function Apps using GitHub Actions
MIT License
152 stars 75 forks source link

Failed to deploy web package to App Service #213

Open craigomatic opened 7 months ago

craigomatic commented 7 months ago

I've started seeing these types of issue with some frequency. My GH action had been functioning earlier today and has stopped working in the past hour or so, blocking deployment with the following error in the logs:  

Error: Failed to deploy web package to App Service.
Internal Server Error (CODE: 500)
    at Kudu.<anonymous> (D:\a\_actions\Azure\functions-action\v1\lib\appservice-rest\Kudu\azure-app-kudu-service.js:235:41)
    at Generator.next (<anonymous>)
    at fulfilled (D:\a\_actions\Azure\functions-action\v1\lib\appservice-rest\Kudu\azure-app-kudu-service.js:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Some of the jobs I have retried a few times and of those, some were then successful.

Not sure if there is a better place to report this?

nicholasdavidbrown commented 7 months ago

I am also seeing this behaviour (this year, as it was deploying fine last year up until mid December).

Only via my GitHub Actions CI/CD though. Deployment via the Azure CLI & extension in VSCode still works and is my workaround for the meantime to deploy functions. Although I still had to rollback my extension versions to get that to work lol see the accepted answer there if you need: https://learn.microsoft.com/en-us/answers/questions/1462401/azure-functions-deployment-error-number-of-entries?source=docs

I have both SCM_DO_BUILD_DURING_DEPLOYMENT and ENABLE_ORYX_BUILD set to defaults (off). But turning them on made no difference. I also tried specifying minor versions of this repo to no avail.

This is my log during the final step of this package execution:

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://[XXX].scm.azurewebsites.net/api/deployments/a03eb5e918017f129c9dfcf55338fc157c0cbe0b1706508547974
Error: Execution Exception (state: PublishContent) (step: Invocation)
Error:   When request Azure resource at PublishContent, zipDeploy : Failed to use D:\a\_temp\temp_web_package_6721177596420238.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!

EDIT: @craigomatic if it helps, my alternative was to use the webapp-deploy azure package instead, as both achieve essentially the same thing. Note: I am using a V4 function app with WEBSITE_RUN_FROM_PACKAGE set to 1.

Here's my new GH Action .yml file:

name: Develop branch CI/CD Pipeline - Building and Deploy API as ZIP to Azure (my-app)

on:
  push:
    branches:
      - develop
  workflow_dispatch:

env:
  AZURE_FUNCTIONAPP_NAME: "my-app"
  AZURE_FUNCTIONAPP_PACKAGE_PATH: "./release.zip"
  NODE_VERSION: "20.x"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up Node.js version
        uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: npm install, build, and test
        run: |
          npm install
          npm run build
          npm run test

      - name: Zip artifact for deployment
        run: zip release.zip ./* -r

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v3
        with:
          name: function-app
          path: release.zip

  deploy:
    runs-on: ubuntu-latest
    needs: build

    steps:
      - name: Set up Node.js version
        uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: Download artifact from build job
        uses: actions/download-artifact@v3
        with:
          name: function-app

      - name: "Deploy to Azure Web App"
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
          slot-name: "production"
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_DEV }}
          package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}

The ZIP file gets uploaded to /data/SitePackages as a ZIP which then triggered the server to restart and copy the ZIp contents over to /site/wwwroot.

My pipeline is now working fine.

craigomatic commented 7 months ago

Thanks for the workaround - I will add this to the backlog, fortunately it started working again for now.

ScotteYx commented 4 months ago

Think this is still a problem. Trying to automate my deployments through actions today and seeing this. Works fine when manually publishing through VS.

ckulka commented 1 month ago

I almost the same error message with a minimally different stack trace, possibly just because of a newer Azure/functions-action version.

It was because the ZIP file was too big.

In my case, the Azure/functions-action creates a ZIP of the folder and uploads that to Azure. I was just experimenting with a TypeScript Function and also included all devDependencies in the deployment, resulting in a ZIP file that was too big. Not including the devDependencies solved that issue.

# Before: deployment fails, because devDependencies are included in the ZIP
- run: |
    npm ci
    npm run build
- uses: Azure/functions-action@v1

# After: deployment works, because devDependencies are not included anymore
- run: |
    npm ci
    npm run build
    npm ci --omit=dev
- uses: Azure/functions-action@v1

Here's the error message I had:

Detected function app language: Node
Will archive ./function-app into /home/runner/work/_temp/temp_web_package_3375067283991009.zip as function app content
Will use https://<scmsite>/api/zipdeploy to deploy since RBAC Azure credential is detected.
Setting WEBSITE_RUN_FROM_PACKAGE to 1
Update using context.appService.patchApplicationSettings
App setting WEBSITE_RUN_FROM_PACKAGE propagated to Kudu container
Validating deployment package for functions app before Zip Deploy (RBAC)
Package deployment using ZIP Deploy initiated.
Error: Failed to deploy web package to App Service.
Error: Execution Exception (state: PublishContent) (step: Invocation)
Error:   When request Azure resource at PublishContent, zipDeploy : Failed to use /home/runner/work/_temp/temp_web_package_3375067283991009.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> (/home/runner/work/_actions/Azure/functions-action/v1/lib/appservice-rest/Kudu/azure-app-kudu-service.js:[23](<omitted>)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/Azure/functions-action/v1/lib/appservice-rest/Kudu/azure-app-kudu-service.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: Deployment Failed!