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).
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.
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.
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.
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.
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=.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With