0

Im asked to test a Google Cloud Function triggered by http through cloud shell using the "curl -m 60 -X GET [url_of_your_function]" commnand.

Does anyone know where to find the url of my function? Ive tried the main url of it and many other ideas but get not solution. I cannot find any documentation on Google Cloud as documentation for GCF its very scarse and disorganized.

1 Answer 1

2

See Function URL on the documentation for Cloud Functions.

The way to parse the describe result depends on whether you're using 1st or 2nd gen.

Once you have the URL, assuming it requires auth, you can:

ENDPOINT="$(gcloud functions describe ... )" TOKEN="$(gcloud auth print-identity-token)" curl \ --get \ --header "Authorization: Bearer ${TOKEN}" \ ${ENDPOINT} 

gcloud includes a command to invoke Cloud Functions directly too:

gcloud functions call ... 
Sign up to request clarification or add additional context in comments.

3 Comments

It's worth to mention that gcloud functions call it's ok when doing sporadical tests since it relies on the Test function per minute quota. For doing lots of requests the recommendation is to make the requests directly to the HTTP endpoint of the function. cloud.google.com/functions/quotas#rate_limits
Hi @DazWilkin, thanks for your answer. When trying to call the function, the following error shows: ERROR: (gcloud.functions.call) ResponseError: status=[404], code=[Ok], message=[Function function-1 in region us-central1 in project fabled-badge-367810 does not exist]
At least one of the parameters is incorrect. 404 means not found. Check the name (function-1), the region (us-central1) and the project (fabled-badge-367810).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.