yambo
yambo

Reputation: 1817

How to Call Google Cloud Function From the Command Line

How do I call my Google Cloud function from the command line? I created a simple Hello World function, that works when I use a curl command to call it, but using the gcloud functions call hello-world command tells me that the function does not exist.

% gcp functions list
NAME         STATE   TRIGGER       REGION       ENVIRONMENT
hello-world  ACTIVE  HTTP Trigger  us-central1  2nd gen

% gcp functions call hello-world
ERROR: (gcloud.functions.call) ResponseError: status=[404], code=[Ok], message=[Function hello-world in region us-central1 in project test-project does not exist]

I thought maybe something was mismatched with the zone, so I set my default region and zone using the following command, but still no luck.

gcloud compute project-info add-metadata \
   --metadata google-compute-default-region=us-central1,google-compute-default-zone=us-central1-a

Upvotes: 1

Views: 1093

Answers (1)

Sarah Remo
Sarah Remo

Reputation: 709

Based on this documentation, Cloud Functions uses the First generation environment if you did not use the --gen2 Flag. You can try this below command:

gcloud functions call hello-world --region us-central1 --gen2

Sample Output: enter image description here

Upvotes: 1

Related Questions