【问题标题】:Unable to deploy fresh Azure Function to Linux app无法将新的 Azure 函数部署到 Linux 应用程序
【发布时间】:2023-02-11 04:40:55
【问题描述】:

我正在尝试将新创建的 Azure Function 部署到 Linux Azure Function 应用程序。出于某种原因,这一直失败,即使功能和应用程序是新创建的。我试过使用 azure cli、VS Code 和 Github Actions,但总是失败。当我将相同的功能部署到 Windows Functions 应用程序时,一切都很顺利。下面是错误输出:

Successfully parsed SCM credential from publish-profile format.
Using SCM credential for authentication, GitHub Action will not perform resource validation.
Successfully acquired app settings from function app (with SCM credential)!
Will archive . into /home/runner/work/_temp/temp_web_package_2443264159027716.zip as function app content
Will use Kudu https:///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.
Updating submodules.
Preparing deployment for commit id '00497852-0'.
PreDeployment: context.CleanOutputPath False
PreDeployment: context.OutputPath /home/site/wwwroot
Repository path is /tmp/zipdeploy/extracted
Running oryx build...
Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform nodejs --platform-version ~16
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20210120.1, Commit: 66c7820d7df527aaffabd2563a49ad57930999c9, ReleaseTagName: 20210120.1

Build Operation ID: |fobbjx9Jh14=.7ba5fe28_
Repository Commit : 00497852-0566-46df-b53b-a3eec6c1e567

Detecting platforms...
Detected following platforms:
nodejs: 16.14.2

Source directory : /tmp/zipdeploy/extracted
Destination directory: /home/site/wwwroot

Using Node version:
v16.14.2

Using Npm version:
8.5.0

Running 'npm install --unsafe-perm'...

up to date, audited 129 packages in 896ms

9 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

Running 'npm run build'...

leadsbeasts@1.0.0 build
tsc

/tmp/zipdeploy/extracted/node_modules/.bin/tsc: 1: /tmp/zipdeploy/extracted/node_modules/.bin/tsc: ../typescript/bin/tsc: not found
/tmp/zipdeploy/extracted/node_modules/.bin/tsc: 1: /tmp/zipdeploy/extracted/node_modules/.bin/tsc: ../typescript/bin/tsc: not found\n/opt/Kudu/Scripts/starter.sh oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform nodejs --platform-version ~16

Generating summary of Oryx build
Deployment Log file does not exist in /tmp/oryx-build.log
The logfile at /tmp/oryx-build.log is empty. Unable to fetch the summary of build
Deployment Failed. deployer = GITHUB_ZIP_DEPLOY deploymentPath = Functions App ZipDeploy. Extract zip. Remote build.
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_package2443264159027716.zip as ZipDeploy content
Error: Package deployment using ZIP Deploy failed. Refer logs for more details.
Error: Deployment Failed!

有谁知道如何解决这一问题?我需要确保我的应用程序是在服务器上构建的,据我所知,使用 Windows 操作系统是不可能的。这是这个设置:“azureFunctions.scmDoBuildDuringDeployment”:true

【问题讨论】:

    标签: node.js linux azure azure-functions


    【解决方案1】:

    在 Azure 门户中创建了 VS Code 中的 Azure Node JS Function App 和 Linux Function App。 检查这些选项,例如 VS 代码部署,CLI:

    1. VS 代码部署输出:
      10:28:37 AM krishnodejsfunapp: Starting deployment...
      10:28:41 AM krishnodejsfunapp: Creating zip package...
      10:28:41 AM krishnodejsfunapp: Uploading zip package to storage container...
      10:28:41 AM krishnodejsfunapp: Zip package size: 1.88 kB
      10:28:47 AM krishnodejsfunapp: Deployment successful.
      10:28:47 AM krishnodejsfunapp: Started postDeployTask "npm install (functions)".
      10:28:59 AM krishnodejsfunapp: Syncing triggers...
      10:29:04 AM krishnodejsfunapp: Querying triggers...
      10:29:09 AM krishnodejsfunapp: HTTP Trigger Urls:
      HttpTrigger1: https://krishnodejsfunapp.azurewebsites.net/api/httptrigger1
      

      2. 使用 CLI 部署到第二个 Linux Function App:

      您可以参考one我的使用Azure CLI cmdlet 部署Function App 的解决方案。

      对于当前的 Function App 部署:

      az login
      az account set --subscription subs-id
      az functionapp config appsettings set --name KrishPy02LinuxFunApp --resource-group HariTestRG --settings "SCM_DO_BUILD_DURING_DEPLOYMENT=true"
      

      它将提供来自该函数应用程序的配置设置值的 JSON 格式输出。

      powershell Compress-Archive C:UsersHarisource
      eposKrishPyFunApp305 C:UsersHarisource
      eposKrishPyFunApp305.zip
      
      az functionapp deployment source config-zip -g HariTestRG -n KrishPy02LinuxFunApp --src "C:/Users/Hari/source/repos/KrishPyFunApp305.zip"
      

      笔记:

      1. 对于 Function 的 zip 部署,我们需要启用 Azure Portal Function App SCM_DO_BUILD_DURING_DEPLOYMENT=true 中的配置设置,如MS Doc 中所指定。
      2. 对于应用程序服务,WEBSITE_WEBDEPLOY_USE_SCM 在部署前在应用程序设置配置中设置为真。

        如果通过 Azure DevOps 部署,请参阅 MS Q& A 论坛中的类似问题。

    【讨论】:

    • 谢谢你的回答。我正在使用 Github Action 进行部署。您知道使用 Github Actions 使其工作的方法吗?
    • 我刚刚尝试了一个新的函数,并设置了应用程序设置 SCM_DO_BUILD_DURING_DEPLOYMENT=true,但它仍然失败。
    • 不知道 GitHub 的操作,但让我检查一下并相应地更新答案!
    【解决方案2】:

    我遇到了类似的问题,问题似乎是我的 Github Action 在 Linux 上运行,而我的 Azure Function App 在 Windows 上运行。当我在 Linux 上重新创建 Azure Function App 时,它起作用了……

    【讨论】:

      【解决方案3】:

      对我来说,它是 ENABLE_ORYX_BUILD 标志(在应用程序服务配置中),出于某种原因在新创建的函数上启用了它。在我禁用它后它起作用了。

      【讨论】:

        猜你喜欢
        • 2016-06-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-08
        • 2020-05-03
        • 2020-01-07
        • 1970-01-01
        • 2021-07-16
        相关资源
        最近更新 更多