0
votes

I am new to deploying action webhooks into GCP, and trying to simply deploy the demo api.ai webhook from here: https://github.com/actions-on-google/apiai-webhook-template-nodejs

Using the instructions from here: https://developers.google.com/actions/samples/

Though I recently noted this pages says "These instructions assume you are using Google App Engine". Not a useful sentence in a Samples / Getting Started page...

When I run gcloud app deploy, it does something for a couple of minutes, then ends with:

(Note that I have hidden part of some keys with 'x's. Not sure what's sensitive, if any):

$ 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
...

This appears to have occurred from an attempted "npm start" (Presumably on the GCP server, right?)

What is functions?

Is this something that is supposed to exist in the environment in GCP that I am deploying to?

It seems I am not the only one encountering this. Also an issue at the github page for the demo I am trying: https://github.com/actions-on-google/apiai-webhook-template-nodejs/issues/1

UPDATE1: I discovered that I didn't have the 'Cloud Functions API' enabled for the relevant GCP project. Strangely, enabling this seems to have made no difference. (When discovered, I thought this was my problem for sure! But no...)

UPDATE2: I also discovered that the 'deploy' commands here seem to want the (exported) function name, NOT the project name, so I have changed from "deploy level-up-xxx" to "deploy levelUpXxxx". But still no joy.

UPDATE3: I came across this 'older' sequence of commands which is still documented at: https://cloud.google.com/functions/docs/tutorials/http Seems to succeed at deploying: (But I haven't yet confirmed this is sufficiently equivalennt to the 'app deploy' I am trying to get working)

(@Prisoner tells me these are not 'older' but a different GCP thing altogether...)

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

Still want/need to get the advertised (non-beta) "gcloud app deploy" thing to work...

Very confused about what's going on...

Could the version of npm I am using at my desktop be an issue? i.e. Too new? Could that be packaging the project up wrong, and it's unhappy inside GCP? Just a theory... I really don't know how it all works at this point...


Resolution

It turns out the main culprit here was that (at the time of writing), the instructions for the demos at https://developers.google.com/actions/samples/ indicate to use gcloud app, whereas the demos themselves seem to have been 'upgraded'(?) to use gcloud beta functions.

Quite confusing if you are new to GCP. (Google would do well to throw more resources at keeping their doco up to date...)

Thanks for the pointer @Prisoner. Answer awarded.

1

1 Answers

2
votes

You're mixing two different serverless Google Cloud environments.

gcloud app deploys something to Google App Engine. You're not showing all the configuration files, but you probably need more configuration to deploy to an App Engine environment. (You can deploy to App Engine running Node, but there is more to it.)

gcloud beta functions deploys something to Google Cloud Functions, which is still in beta. (But remember... Google has kept products and services that are working quite well in beta for years...)