Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud Functions Resource Exhausted

Hello.

I'm taking my first steps with cloud functions (1 gen) http trigger and I'm having problems calling my functions using the nodejs @google-cloud/functions lib.
I'm making the calls using the CloudFunctionsServiceClient's callFunction method, however, after a few successful calls I start to receive an error due to the function test quota overflow. 
Researching I discovered that the callFunctions method should not be used in production but I couldn't find out how to make calls without using this method.

My code is like this below

 

  const name = 'abc123'
  const data = 'abc123'

  const {CloudFunctionsServiceClient} = require('@google-cloud/functions').v1;
  const functionsClient = new CloudFunctionsServiceClient();

  async function callCallFunction() {
    const request = {
      name,
      data,
    };

    const response = await functionsClient.callFunction(request);
    console.log(response);
  }

  callCallFunction();

 

I would be very grateful if you could help me with this.




0 1 400
1 REPLY 1

As shown in the quickstart Create and deploy a HTTP Cloud Function by using Node.js, in section Testing the function, you can get the https trigger url as follows:

When the function finishes deploying, take note of the httpsTrigger.url property or find it using the following command:

gcloud functions describe functionName

It should look like this:

https://GCP_REGION-PROJECT_ID.cloudfunctions.net/helloHttp

Then, with that url you can call your function with Postman as shown on this answer on Stack Overflow:

cristianrm_0-1657744991154.png

 

Another way is to call your function from the console, as shown in the documentation:

  1. Display the menu for your function, and click Test function.
    cristianrm_1-1657744991153.png

     

  2. On the testing page, click Test the function.
    The Output screen displays the text "Hello World!"
  3. Now change the message. In the Triggering Event field, enter the text {"message":"Hello, YOUR_NAME!"}, replacing YOUR_NAME with a name, and click Test the function.
    For example, suppose you entered the name "Rowan". In the Output field, you would see the message Hello, Rowan!.
    In the Logs field, a status code of 200 indicates success.
    cristianrm_2-1657744991118.png

     

Finally, for debugging purposes, you could also call your function directly using the Google Cloud CLI:

To directly invoke a function using the gcloud CLI, use the gcloud functions call command and supply any data your function expects as JSON in the --data argument. For example:

gcloud functions call YOUR_FUNCTION_NAME --data '{"name":"Keyboard Cat"}'

See also: