-
Notifications
You must be signed in to change notification settings - Fork 115
Using the Emulator with the Cloud SDK
Table of Contents
- Configuring the SDK to use the Emulator
- Listing locally deployed functions
- Describing a locally deployed function
- Calling locally deployed functions
- Deleting a locally deployed function
- Cloud SDK commands that don't work with the Emulator
View your current SDK configuration:
gcloud config list
you'll probably see something like this:
Your active configuration is: [default]
[compute]
region = us-central1
zone = us-central1-c
[core]
account = [email protected]
project = YOUR_PROJECT_ID
You probably want your default Cloud SDK configuration to talk the production Google Cloud Functions service, so we'll make a new configuration that will talk to the Emulator:
gcloud config configurations create emulator
In your new configuration, copy over some of the values from your default config:
gcloud config set account [email protected]
gcloud config set project YOUR_PROJECT_ID
Now tell the new configuration to talk to the Emulator instead of the production Cloud Functions service. This involves setting api_endpoint_overrides/cloudfunctions
to the hostname of the Emulator's REST service:
gcloud config set api_endpoint_overrides/cloudfunctions http://localhost:8008/
You can verify the hostname of the Emulator's REST service with:
functions status
which should print an entry like this:
├────────────────┼───────────────────────────┤
│ REST Service │ http://localhost:8008/ │
├────────────────┼───────────────────────────┤
You can switch back to your default Cloud SDK configuration at any time:
gcloud config configurations activate default
gcloud alpha functions list
gcloud alpha functions describe helloWorld
gcloud alpha functions call helloWorld --data='{"type":"pizza"}'
gcloud alpha functions delete helloWorld
The following Cloud SDK commands don't work with the Emulator:
-
gcloud alpha functions logs read
- The Cloud SDK only knows how to read logs in the Cloud, not the local logs.
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.