Skip to content
This repository was archived by the owner on May 15, 2019. It is now read-only.

Using the Emulator with the Cloud SDK

Jason Dobry edited this page Dec 30, 2016 · 7 revisions

Table of Contents

Configuration the SDK to use 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 compute/region us-central1
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

Listing locally deployed functions

gcloud alpha functions list

Calling locally deployed functions

gcloud alpha functions call helloWorld --data='{"type":"pizza"}'
Clone this wiki locally