-
Notifications
You must be signed in to change notification settings - Fork 115
Calling functions
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 alpha functions call helloWorld
or
curl https://location-YOUR_PROJECT_ID.cloudfunctions.net/helloWorld
With the Emulator it's very similar:
functions call helloWorld
or
curl http://localhost:8010/YOUR_PROJECT_ID/location/helloWorld
To get help on the call
command run:
functions call --help
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:
functions call helloWorld --data='{"message":"Hello, World"}'
or
functions call helloWorld --file=/path/to/data.json
To call a helloWorld
background function that's been deployed to the production Google Cloud Functions service you might run the following command:
gcloud alpha 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:
functions call helloWorld --data='{"name":"somefile"}'
or
functions call helloWorld --file=/path/to/data.json
Disclaimer: This is not an official Google product.
@google-cloud/functions-emulator is currently in pre-1.0.0 development. Before the 1.0.0 release, backwards compatible changes and bug fixes will bump the patch version number and breaking changes will bump the minor version number.