gpt4 book ai didi

node.js - 无法将新的 Azure Functions 部署到 Linux 应用程序

转载 作者:行者123 更新时间:2023-12-02 08:15:20 25 4
gpt4 key购买 nike

我正在尝试将新创建的 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'...

<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0f636a6e6b7c6d6a6e7c7b7c4f3e213f213f" rel="noreferrer noopener nofollow">[email protected]</a> 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

最佳答案

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

  1. VS Code 部署输出:
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

enter image description here

<强>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:\Users\Hari\source\repos\KrishPyFunApp305 C:\Users\Hari\source\repos\KrishPyFunApp305.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 设置为 true。

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

关于node.js - 无法将新的 Azure Functions 部署到 Linux 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74195407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com