最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Azure Function deployment from GitHub action is failing in Azurefunctions-action - Stack Overflow

programmeradmin2浏览0评论

I have created an Azure function with Node in VS Code and published it to Github. In GitHub, I have created a build-and-deploy action YAML:

name: Deploy Node.js project to Azure Function App

on:
  push:
    branches: ["main"]

env:
  AZURE_FUNCTIONAPP_NAME: 'express-addon-analytics'   # set this to your function app name on Azure
  AZURE_FUNCTIONAPP_PACKAGE_PATH: 'azure-function'       # set this to the path to your function app project, defaults to the repository root
  NODE_VERSION: '20.x'                      # set this to the node version to use (e.g. '8.x', '10.x', '12.x')

jobs:
  build-and-deploy:
    runs-on: windows-latest # For Linux, use ubuntu-latest
    environment: dev
    steps:
    - name: 'Checkout GitHub Action'
      uses: actions/checkout@v4

    # If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
    # - name: 'Login via Azure CLI'
    #   uses: azure/login@v1
    #   with:
    #     creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository

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

    - name: 'Resolve Project Dependencies Using Npm'
      shell: pwsh # For Linux, use 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/[email protected]
      id: fa
      with:
        app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
        package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
        publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} 

but the code fails in the Azure/functions-action with this (removing retries for brevity):

Successfully parsed SCM credential from publish-profile format.
Using SCM credential for authentication, GitHub Action will not perform resource validation.
(node:2544) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Successfully acquired app settings from function app (with SCM credential)!
Will archive azure-function into D:\a\_temp\temp_web_package_05553268543987899.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 false
Update using context.kuduService.updateAppSettingViaKudu
Response with status code 405
App setting SCM_DO_BUILD_DURING_DEPLOYMENT has not been propagated to Kudu container yet, remaining retry 19
App setting SCM_DO_BUILD_DURING_DEPLOYMENT has not been propagated to Kudu container yet, remaining retry 1
App setting SCM_DO_BUILD_DURING_DEPLOYMENT has not been propagated to Kudu container yet, remaining retry 0
Warning: App setting SCM_DO_BUILD_DURING_DEPLOYMENT fails to propagate to Kudu container
Setting ENABLE_ORYX_BUILD in Kudu container to false
Update using context.kuduService.updateAppSettingViaKudu
Response with status code 405
App setting ENABLE_ORYX_BUILD has not been propagated to Kudu container yet, remaining retry 19
App setting ENABLE_ORYX_BUILD has not been propagated to Kudu container yet, remaining retry 1
App setting ENABLE_ORYX_BUILD has not been propagated to Kudu container yet, remaining retry 0
Warning: App setting ENABLE_ORYX_BUILD fails to propagate to Kudu container
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 D:\a\_temp\temp_web_package_05553268543987899.zip as ZipDeploy content
Error:     Failed to deploy web package to App Service.
Not Found (CODE: 404)
Error:       Error: Failed to deploy web package to App Service.
Not Found (CODE: 404)
    at Kudu.<anonymous> (D:\a\_actions\Azure\functions-action\v1.5.1\lib\appservice-rest\Kudu\azure-app-kudu-service.js:235:41)
    at Generator.next (<anonymous>)
    at fulfilled (D:\a\_actions\Azure\functions-action\v1.5.1\lib\appservice-rest\Kudu\azure-app-kudu-service.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: Deployment Failed!

The Azure function is live and I used a publisher profile from it in a secret on Github.

Does anyone have any suggestions?

I have created an Azure function with Node in VS Code and published it to Github. In GitHub, I have created a build-and-deploy action YAML:

name: Deploy Node.js project to Azure Function App

on:
  push:
    branches: ["main"]

env:
  AZURE_FUNCTIONAPP_NAME: 'express-addon-analytics'   # set this to your function app name on Azure
  AZURE_FUNCTIONAPP_PACKAGE_PATH: 'azure-function'       # set this to the path to your function app project, defaults to the repository root
  NODE_VERSION: '20.x'                      # set this to the node version to use (e.g. '8.x', '10.x', '12.x')

jobs:
  build-and-deploy:
    runs-on: windows-latest # For Linux, use ubuntu-latest
    environment: dev
    steps:
    - name: 'Checkout GitHub Action'
      uses: actions/checkout@v4

    # If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below
    # - name: 'Login via Azure CLI'
    #   uses: azure/login@v1
    #   with:
    #     creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository

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

    - name: 'Resolve Project Dependencies Using Npm'
      shell: pwsh # For Linux, use 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/[email protected]
      id: fa
      with:
        app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
        package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
        publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} 

but the code fails in the Azure/functions-action with this (removing retries for brevity):

Successfully parsed SCM credential from publish-profile format.
Using SCM credential for authentication, GitHub Action will not perform resource validation.
(node:2544) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Successfully acquired app settings from function app (with SCM credential)!
Will archive azure-function into D:\a\_temp\temp_web_package_05553268543987899.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 false
Update using context.kuduService.updateAppSettingViaKudu
Response with status code 405
App setting SCM_DO_BUILD_DURING_DEPLOYMENT has not been propagated to Kudu container yet, remaining retry 19
App setting SCM_DO_BUILD_DURING_DEPLOYMENT has not been propagated to Kudu container yet, remaining retry 1
App setting SCM_DO_BUILD_DURING_DEPLOYMENT has not been propagated to Kudu container yet, remaining retry 0
Warning: App setting SCM_DO_BUILD_DURING_DEPLOYMENT fails to propagate to Kudu container
Setting ENABLE_ORYX_BUILD in Kudu container to false
Update using context.kuduService.updateAppSettingViaKudu
Response with status code 405
App setting ENABLE_ORYX_BUILD has not been propagated to Kudu container yet, remaining retry 19
App setting ENABLE_ORYX_BUILD has not been propagated to Kudu container yet, remaining retry 1
App setting ENABLE_ORYX_BUILD has not been propagated to Kudu container yet, remaining retry 0
Warning: App setting ENABLE_ORYX_BUILD fails to propagate to Kudu container
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 D:\a\_temp\temp_web_package_05553268543987899.zip as ZipDeploy content
Error:     Failed to deploy web package to App Service.
Not Found (CODE: 404)
Error:       Error: Failed to deploy web package to App Service.
Not Found (CODE: 404)
    at Kudu.<anonymous> (D:\a\_actions\Azure\functions-action\v1.5.1\lib\appservice-rest\Kudu\azure-app-kudu-service.js:235:41)
    at Generator.next (<anonymous>)
    at fulfilled (D:\a\_actions\Azure\functions-action\v1.5.1\lib\appservice-rest\Kudu\azure-app-kudu-service.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: Deployment Failed!

The Azure function is live and I used a publisher profile from it in a secret on Github.

Does anyone have any suggestions?

Share Improve this question asked Feb 16 at 1:20 Michael S. ScherotterMichael S. Scherotter 10.8k3 gold badges37 silver badges59 bronze badges 2
  • Have you downloaded the publish profile from Azure Function App > Overview > Get publish profile and added it to GitHub Repository > Settings > Secrets and variables > Actions > New repository secret as AZURE_FUNCTIONAPP_PUBLISH_PROFILE? – Dasari Kamali Commented Feb 16 at 12:02
  • Yes - I have downloaded the publish profile and added it to the secrets with that key. – Michael S. Scherotter Commented Feb 17 at 4:28
Add a comment  | 

1 Answer 1

Reset to default 1

If you are using the Publish Profile authentication in your GitHub workflow, make sure to turn on the SCM Basic Auth Publishing Credentials by setting it to On in the Azure Function App > Configuration as shown below.

I downloaded the publish profile from the Azure Function App > Overview > Get publish profile.

And, I added the complete publish profile data to the GitHub Repository > Settings > Secrets and variables > Actions > New repository secret as shown below.

Name : AZURE_FUNCTIONAPP_PUBLISH_PROFILE

Secret : Paste the entire publish profile file data

I have updated the project location to . in the workflow file, which represents the root directory of my repository.

AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'  

Workflow YAML file :

name: Deploy Node.js project to Azure Function App

on:
  push:
    branches: ["main"]

env:
  AZURE_FUNCTIONAPP_NAME: 'kamfunGit'  # Change this to FunctionAppName in your publish profile
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'  # Path to your function app code
  NODE_VERSION: '20.x'  

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

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

    - name: 'Resolve Project Dependencies Using Npm'
      shell: pwsh
      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/[email protected]
      id: fa
      with:
        app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
        package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
        publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }}

The sample Nodejs project was successfully deployed from GitHub Actions to the Azure Function App.

发布评论

评论列表(0)

  1. 暂无评论