从Github Actions部署Azure函数会崩溃,WEBSITE_RUN_FROM_PACKAGE=1

vfwfrxfs  于 2023-08-07  发布在  Git
关注(0)|答案(1)|浏览(119)

上下文:我有一个部署Azure函数的GitHub Action。每次有人推到'dev'分支时,它都会崩溃。唯一的手动“变通办法”我发现的工作是以下;
1.前往Azure的Function App > Configuration > Application Settings
1.删除WEBSITE_RUN_FROM_PACKAGE=1配置
1.重新运行GitHub Actions上的所有作业(像这样成功)
1.再次添加WEBSITE_RUN_FROM_PACKAGE=1配置,否则我会陷入使用msal(NodeJS)的登录循环中
请注意,我有两个环境。一个是“dev”,另一个是“prod”。
GitHub操作失败作业描述:

Run Azure/functions-action@v1.3.2
  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/workflow/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/functions-action@v1.3.2
        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


x1c 0d1x的数据

z2acfund

z2acfund1#

我尝试使用Github操作从Master分支然后从Dev分支部署Azure Function Http触发器,并且成功,在这两个分支中,请参阅下面:-

主分支:-

x1c 0d1x的数据

我的仓库:-

  • function.json和index.js在HttpTrigger 1文件夹内,其他文件在HttpTrigger 1文件夹外。*


我的github动作流程:-

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 }}

字符串


我的开发分支:-



x1c4d 1x的

我的github操作工作流程:-

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 }}



  • 注意-我在Linux操作系统中创建了Function应用程序。*
  • 为了解决您的错误,请确保您的函数触发器文件夹格式正确,如上文在dev分支中,没有文件夹或包丢失,并且两个分支是同步的。github action workflow将自动启动zip部署,并在必要时添加函数应用设置。
  • 清除之前的github操作工作流,删除工件和github操作缓存,并通过Azure Portal > Deployment Center重新运行Function应用工作流,并连接到您的Github帐户和Function分支。

相关问题