Azure Function 已成功部署,但无法正常工作

Azure Function deployed successfully, but not working

我遇到了一个奇怪的问题。我使用 Azure DevOps Pipeline Release 部署了我的代码 - 它 运行 成功,但是,代码没有反映在 Azure Function App 中。

这是我正在做的事情:

  1. 使用“部署 Azure 应用服务”任务创建了发布管道。它从构建管道中获取工件,并配置为使用服务连接
  2. 部署到功能应用程序
  3. 触发发布管道后,它会运行所有步骤,我获得了成功(请参阅下面的日志)
  4. 但是,当我打开 Azure 门户并导航到 Function App 时,它继续在 Overview[=46 上显示 "Now it is time to add your code" =] 选项卡,我无法在那个 Function App
  5. 上点击我的 API
  6. 令人惊讶的是,在函数应用程序的部署中心选项卡上,它确实显示了部署的详细信息(详见下文)
  7. 登录Kudu控制台也能在D:\home\site\wwwroot下找到部署好的zip文件

部署日志:

Got service connection details for Azure App Service:'myFuncApp'
Updating App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"1"}
Updated App Service Application settings and Kudu Application settings.
Package deployment using ZIP Deploy initiated.
Successfully deployed web package to App Service.
App Service Application URL: http://myFuncApp.azurewebsites.net

在功能应用部署中心选项卡上查看:

Deployed Successfully to production
 Source Version 6d9c8340ba  Build 20190411.1  Release: 3

Function App 端点正在运行,(抛出一个通用的欢迎页面)确认 Function App 本身是健康的,但我无法访问我的 API。

其他更新 这是作为 Azure Pipelines zip 部署的一部分上传到 d:\home\data\SitePackages 的 .zip 文件的结构:

/host.json
/package.json
/proxies.json
/package-lock.json
/func_name/index.js
/func_name/function.json
/node_modules/**

相同的代码在本地运行。

注意:当我转到 Deployment Center 选项卡时,我确实看到了这条错误消息,但我认为这与通过 Function App 持续部署有关

We were unable to connect to the Azure Pipeline that is connected to this Web App. This could mean it has been removed from the Azure Dev Ops Portal. If this has happened, you can disconnect this pipeline and set up a new deployment pipeline.

请帮助我。可能出了什么问题?

我终于可以排除故障了。 @4c74356b41 为我指出了正确的方向,因为关键问题是包。

问题如下:

  • 我在构建管道中添加了 archive 步骤。这导致工件在发布前被压缩
  • 在发布管道中,我使用了 Azure App Service Deploy 任务。这在内部使用 Zip Deploy,其中 App type 设置为 Azure Functions。因此,它正在压缩我的压缩文件。

当我删除存档步骤时,避免了双重压缩,它开始工作了。