"functions: not found" 在 "gcloud app deploy" 期间

"functions: not found" during "gcloud app deploy"

我不熟悉将操作 webhook 部署到 GCP 中,并尝试从此处简单地部署演示 api.ai webhook:https://github.com/actions-on-google/apiai-webhook-template-nodejs

使用此处的说明:https://developers.google.com/actions/samples/

虽然我最近注意到这个页面说 "These instructions assume you are using Google App Engine"。示例/入门页面中没有有用的句子...

当我 运行 gcloud app deploy 时,它做了几分钟的事情,然后以:

(请注意,我用'x'隐藏了一些键。不确定什么是敏感的,如果有的话):

$ gcloud app deploy
You are about to deploy the following services:
 - level-up-xxxx/default/20170625t233004 (from [/home/peter/Projects__/xxxx/webhook/app.yaml])
     Deploying to URL: [https://level-up-xxxx.appspot.com]

Do you want to continue (Y/n)?  y

If this is your first deployment, this may take a while...done.                                                        

Beginning deployment of service [default]...
Building and pushing image for service [default]

... {DETAILS OMITTED FROM HERE} ...

57fff86xxxxx: Pushed
c4a3d3bxxxxx: Pushed
90c3ed3xxxxx: Pushed
latest: digest: sha256:6d06015bb56b73145d91884a477463d5bef03dfb24882a07ce46492bxxxxxxxx size: 2626
DONE
------------------------------------------------------------------------------------------------------------------------

Updating service [default]...failed.                                                                                   
ERROR: (gcloud.app.deploy) Error Response: [9] 
Application startup error:

> level-up-xxxx@0.0.1 start /app
> functions deploy level-up-xxxx --trigger-http

sh: 1: functions: not found

npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "start"
npm ERR! node v6.0.0
npm ERR! npm  v3.8.6
...

这似乎是由于尝试 "npm start"(大概是在 GCP 服务器上,对吧?)

什么是 functions

这是我要部署到的 GCP 环境中应该存在的东西吗?

看来我不是唯一遇到这种情况的人。在我正在尝试的演示的 github 页面上还有一个问题:https://github.com/actions-on-google/apiai-webhook-template-nodejs/issues/1

更新 1:我发现我没有为相关的 GCP 项目启用 'Cloud Functions API'。奇怪的是,启用它似乎没有什么不同。 (发现的时候我还以为是我的问题呢!但是不是...)

UPDATE2:我还发现这里的 'deploy' 命令似乎需要(导出的)函数名称,而不是项目名称,所以我从 "deploy level-up-xxx" 更改为 "deploy levelUpXxxx" .但是还是不开心。

更新 3:我遇到了这个 'older' 命令序列,它仍然记录在:https://cloud.google.com/functions/docs/tutorials/http 似乎 成功 部署:(但我还没有确认这是否足够等同于 'app deploy' 我正在努力工作)

(@Prisoner 告诉我这些不是 'older' 而是完全不同的 GCP 东西...)

$ gsutil mb gs://level-up-xxxx
$ gcloud beta functions deploy LevelUpXxxx --stage-bucket level-up-xxxx --trigger-http

仍然 want/need 获得广告(非测试版)"gcloud app deploy" 的东西......

对发生的事情感到非常困惑...

我在桌面上使用的 npm 版本是否有问题?即太新? 这会不会是项目打包错误,导致 GCP 内部不愉快?只是一个理论......我真的不知道这一切在这一点上是如何运作的......


分辨率

原来这里的罪魁祸首是(在撰写本文时),https://developers.google.com/actions/samples/ 上的演示说明指示使用 gcloud app,而演示本身似乎是'upgraded'(?) 使用 gcloud beta functions.

如果您是 GCP 的新手,会感到很困惑。 (Google 最好投入更多资源来使他们的 doco 保持最新...)

感谢@Prisoner 指点。答案已获得。

您正在混合使用两种不同的无服务器 Google 云环境。

gcloud app 将一些东西部署到 Google App Engine。您没有显示所有配置文件,但您可能需要更多配置才能部署到 App Engine 环境。 (您 可以 部署到 App Engine 运行 节点,但还有更多。)

gcloud beta functions 将一些东西部署到 Google Cloud Functions,它仍处于测试阶段。 (但请记住...Google 多年来一直保持在测试版中运行良好的产品和服务...)