Table of Contents
The Emulator CLI's call
commands mirrors that of the Cloud SDK. To call a helloWorld
HTTP function that's been deployed to the production Google Cloud Functions service you might run one of the following commands:
gcloud beta functions call helloWorld
or
curl https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/helloWorld
With the Emulator it's very similar:
functions call helloWorld
or
curl http://localhost:8010/YOUR_PROJECT_ID/local/helloWorld
To get help on the call
command run:
To get the exact Trigger URL of a locally deployed helloWorld
HTTP function, you would run the following:
functions describe helloWorld
To pass data to an HTTP function using the call
command, use either the --data
or --file
flags:
On Linux/Mac:
functions call helloWorld --data='{"message":"Hello, World"}'
On Windows:
functions call helloWorld --data '{\"message\":\"Hello, World\"}'
or
functions call helloWorld --file=/path/to/data.json
If your HTTP function sends a response body then it will be printed to your terminal. If your function logs any data then you can view those logs with:
Calling background functionsTo call a helloWorld
background function that's been deployed to the production Google Cloud Functions service you might run the following command:
gcloud beta functions call helloWorld
With the Emulator it's very similar:
functions call helloWorld
To pass data to a background function using the call
command, use either the --data
or --file
flags:
On Linux/Mac:
functions call helloWorld --data='{"message":"Hello, World"}'
On Windows:
functions call helloWorld --data '{\"message\":\"Hello, World\"}'
or
functions call helloWorld --file=/path/to/data.json
If your background function synchronously returns data, returns a promise that resolves with data, or passes data to the callback, then that data will be printed to your terminal. If your function logs any data then you can view those logs with:
Cloud Storage bucket triggerYou can manually simulate a Cloud Storage file when you call the function, for example:
On Linux/Mac:
functions call helloWorld --data='{"name":"test.txt","bucket":"my-bucket"}'
On Windows:
functions call helloWorld --data '{\"name\":\"test.txt\",\"bucket\":\"my-bucket\"}'
Cloud Pub/Sub topic trigger
You can manually simulate a Cloud Pub/Sub message when you call the function, for example:
On Linux/Mac:
functions call helloWorld --data='{"data":"Sm9obg=="}'
On Windows:
functions call helloWorld --data '{\"data\":\"Sm9obg==\"}'
where "Sm9obg=="
is "John"
encoded as a base64
string.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4