Run locally with Functions Framework

This page shows you how to install and run Functions Frameworks for local development.

Before you begin

If this is your first time using Cloud Functions with Cloud Code, see the Create and deploy a function quickstart. Once you've created and deployed a function using a Cloud Code sample, you can return to this guide to setup a local development environment.

Install and run Functions Framework locally

To install and run Functions Framework locally, follow these steps:

  1. In VS Code, click Cloud Code and then expand the Cloud Functions explorer.

  2. Expand your Google Cloud project, right-click a deployed function of your choice, and select Download to new workspace. This downloads the source code of your function from Google Cloud to your local machine and creates a new workspace in your IDE.

  3. Click View > Terminal to open the terminal in VS Code.

  4. To install the local dependencies to your function's local folder, navigate to your function's local folder in the terminal and then run the following:

    Node.js

    npm install
    

    Python

    pip install functions-framework
    
  5. To run the local Functions Framework, run the following:

    Node.js

    npx functions-framework --target=entryPoint

    Python

    functions-framework --target=entryPoint

    To find the entryPoint of your function, open your launch.json file and look for the assigned value of entryPoint.

    For example, if you're using Cloud Code's Hello World sample application, the configuration appears as follows:

    "entryPoint": "helloHttp",
    
  6. To test your function, when prompted, click Open in Browser, or click + New Terminal and run the following:

      curl http://localhost:8080/
    

    This shows the context of the function in the terminal.

For more information on how to call locally running functions, see Running Functions with Function Frameworks.

Get Support

To send feedback, report issues on GitHub, or ask a question on Stack Overflow.