Create a 1st gen Cloud Function by using the Google Cloud console

Cloud Functions is a serverless execution environment for building and connecting cloud services. With Cloud Functions you write simple, single-purpose functions that are attached to events emitted from your cloud infrastructure and services. Your function is triggered when an event being watched is fired, or by an HTTP request.

This page shows how to create and deploy a 1st gen HTTP function using the Google Cloud console.


To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:

Guide me


Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Cloud Functions and Cloud Build APIs.

    Enable the APIs

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Cloud Functions and Cloud Build APIs.

    Enable the APIs

Create a function

  1. Open the Functions Overview page in the Google Cloud console:

    Go to the Cloud Functions Overview page

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

  2. Click Create function.

  3. For the Environment, select 1st gen.

  4. Name your function, for example, function-1.

    The name you give your function can include lowercase letters, numbers, and hyphens.

  5. In the Trigger field, select HTTP.

  6. In the Authentication field, select Require Authentication.

    The other option, Allow unauthenticated invocations, lets you reach the function without authentication. This is useful for testing, but we don't recommend using this setting in production unless you are creating a public API or website. Further, it might not work for you, depending on your corporate policy settings. See Authenticating for invocation for details on how to invoke a function that requires authentication.

  7. Click Save to save your changes, and then click Next.

  8. In the Source code field, select Inline editor. In this exercise, you will use the default "Hello World" function provided in the editor.

  9. Use the Runtime drop-down to select your chosen language runtime.

Deploy the function

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

  2. Click the icon to return 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 deployment process

Test the function

  1. Display the menu for your function and select Test function.

    Screenshot that shows function testing process

  2. On the testing page, click Test the function.

    The Output screen displays the text "Hello World!"

  3. Now change the message. In the Triggering Event field, enter the text {"message":"Hello, YOUR_NAME!"}, replacing YOUR_NAME with a name, and click Test the function.

    For example, suppose you entered the name "Rowan". In the Output field, you would see the message Hello, Rowan!.

    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:

  • 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