Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i update Google Cloud Function source?

I've used this command to deploy a function from local source:

gcloud beta functions deploy helloWorld --trigger-http

Now, i have updated it's code. How do i deploy my changes?

When i'm using the same command, it returns status success with some details, but the deployed function remains intact (it uses the very first version of deployed code).

like image 702
stkvtflw Avatar asked Dec 18 '17 17:12

stkvtflw


People also ask

How do I change the cloud function?

While the Cloud functions are not editable on the console the work around is is tu use the Cloud Functions API to retrive the code, then you can edit the code on your local host and finally deploy it again with the corrections with the gcloud command.

What is entry point in cloud function?

The --entry-point flag specifies the entry point to your function in your source code. This is the code that will be executed when your function runs. The value of this flag must be a function name or fully-qualified class name that exists in your source code. See Function entry point for more information.

Why does cloud deployment fail?

Cloud Functions deployment can fail if the entry point to your code, that is, the exported function name, is not specified correctly. Your source code must contain an entry point function that has been correctly specified in your deployment, either via Cloud console or Cloud SDK.


2 Answers

I am running into the same issue. I've deployed my original HTTP function, updated the source, and am now trying to redeploy.

This could perhaps be a bug in the gcloud CLI, but I was able to successfully redeploy from my local machine by leveraging the --source command line flag. Be sure to point this flag to the directory containing your index.js.

gcloud beta functions deploy helloWorld --source=/usr/local/path/to/source/dir --http-trigger

Where index.js would be located at /usr/local/path/to/source/dir/index.js. Further CLI documentation can be found at https://cloud.google.com/sdk/gcloud/reference/beta/functions/deploy.

like image 96
Collin Trowbridge Avatar answered Nov 05 '22 00:11

Collin Trowbridge


Providing an updated answer for anyone that needs it. If you are wanting to just redeploy a function from source the following works assuming you are in the directory of the index.js file. And to clarify this is to redeploy to a gcp function that already exists, not a new one.

gcloud functions deploy <FUNCTION_NAME> --source=.
like image 21
technoY2K Avatar answered Nov 05 '22 02:11

technoY2K