Quickstart: Using the Console

This page shows you how to create and deploy a Cloud Function using the GCP Console.

Before you begin

  1. Sign in to your Google account.

    If you don't already have one, sign up for a new account.

  2. Select or create a Cloud Platform project.

    Go to the Manage resources page

  3. Enable billing for your project.

    Enable billing

  4. Enable the Cloud Functions API.

    Enable the API

  5. Install and initialize the Cloud SDK.
  6. Update and install gcloud components:
    gcloud components update &&
    gcloud components install beta
  7. Need a command prompt? You can use the Google Cloud Shell. The Google Cloud Shell is a command line environment that already includes the Google Cloud SDK, so you don't need to install it. (The Google Cloud SDK also comes preinstalled on Google Compute Engine Virtual Machines.)

  8. Prepare your environment for Node.js development.

    Go to the setup guide

Create a function

  1. Go to Cloud Functions Overview page in the GCP Console.

    Make sure that the project for which you enabled Cloud Functions is selected.

  2. Click Create function.

    Screenshot that shows how to start function creation process

  3. Name your function.

  4. In the Trigger field, select HTTP Trigger.

  5. In the Source code field, select Inline editor. In this exercise, you will use the default helloWorld function implementation provided for index.js. The function logs a message that you provide in a later step.

When you finish these steps, your display should resemble the following:

Screenshot showing function creation form

Create a Cloud Storage bucket

Create a new Cloud Storage bucket for your function:

  1. In the Stage bucket field, click Browse.

    Screenshot that shows bucket creation process

  2. Click the bucket icon to create a stage bucket, and name the bucket. Screenshot that shows bucket creation process

    Note that bucket names must be globally unique. If the name you provide is not globally unique, you will get an error.

  3. Click Create.

  4. Click Select to select the bucket you just created.

    Screenshot that shows bucket creation process

Once you finish these steps, you can scroll down to see the bucket you selected, as well as the helloWorld function ready to deploy.

Screenshot showing bucket and function, ready to deploy

Deploy a function

Deploy the helloWorld function:

  1. At the bottom of the page, click Create.

  2. After clicking Create, GCP Console redirects to the Cloud Functions Overview page.

    While the function is being deployed, the icon next to it is a small spinner. After it finishes deploying, the spinner turns to a green check mark:

    Screenshot that shows function testing process

Test the function

Test the function:

  1. Display the menu for your function, and click Test function.

    Screenshot that shows function testing process

  2. In the Triggering Event field, enter the text {"message":"Hello World!"}, and click Test the function.

    In the Output field, you should see the message Success: Hello World!.

    In the Logs field, a status code of 200 indicates success.

    Screenshot showing Logs field with 200 code, indicating success

View logs

Check the logs to see your actions in the log history:

  1. Back on the Cloud Functions Overview page, display the menu for your function, and click View logs.

Your log history appears.

Screenshot showing Logs field with 200 code, indicating success

What's next

Send feedback about...

Cloud Functions Documentation