Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.
Jason Dobry edited this page Dec 22, 2016 · 23 revisions

Google Cloud Functions Emulator

NPM Tests Coverage

Disclaimer: This is not an official Google product.

Table of Contents

What is this?

The Google Cloud Functions Emulator is a Node.js application that implements the Google Cloud Functions API, and includes a CLI with which it can be managed.

The Emulator allows you to deploy, run, and debug your Cloud Functions on your local machine before deploying them to the production Google Cloud Functions service.

How do I get started?

  1. Sign up for the Google Cloud Functions Alpha and explore the Cloud Functions Documentation.

  2. Write a function:

     mkdir helloworld
     cd helloworld
     touch index.js
     echo 'exports.helloWorld = (req, res) => res.send("Hello, World!");' > index.js
    
  3. Install the Emulator:

    NPM:

     npm install -g @google-cloud/functions-emulator
    

    Yarn:

     yarn global add @google-cloud/functions-emulator
    

    Or read more in the detailed installation instructions.

  4. Start the Emulator:

     functions start
    
  5. Deploy your function:

     functions deploy helloWorld --trigger-http
    
  6. Call your function:

     functions call helloWorld
    
  7. View the logs:

     functions logs read
    

Where is the documentation?

For a quick reference, the Emulator CLI is self-documenting. Run the following to get help with the CLI:

functions --help

For everything else see the How-To Guides.