Deploying from GCP Console

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

Create a function

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

    Make sure that the project to which you want to deploy Cloud Functions is selected.

  2. Click Create function.

  3. Name your function.

  4. In the Memory allocated field, adjust your memory allocation as needed.

  5. In the Trigger field, select your desired trigger.

    HTTP is selected by default. Functions that are triggered by HTTP requests are called HTTP functions. Functions that are triggered by anything else (for example, by a message being published to a Pub/Sub topic) are called background functions. To learn about the different types of triggers and how to use them, see Calling Cloud Functions.

  6. In the Source code field, select one of the following options:

    • Inline editor:

      • Use the GCP Console inline editor to directly enter your source code and dependencies.

      • In the Function to execute field, type the name of the function you provided in the inline editor.

    • ZIP upload:

      • Click Browse in the ZIP file field to upload a ZIP file from your local file system. This ZIP file must include all source files necessary for your function deployment. See Structuring source code for more information.

      • Click Browse in the Stage bucket field to select a stage bucket. Your code will be staged in this Cloud Storage bucket as part of deployment.

      • In the Function to execute field, type the name of your entrypoint function. This function must be available in your source file.

    • ZIP from Cloud Storage:

      • Click Browse in the Cloud Storage location field to upload a ZIP file from Cloud Storage. This ZIP file must include all source files necessary for your function deployment. See Structuring source code for more information.

      • In the Function to execute field, type the name of your entrypoint function. This function must be available in your source file.

    • Cloud Source repository: Upload source code from a Cloud Source repository.

      • In the Repository field, supply the name of the repository, or accept the default.

      • In the Branch / tag field, select Branch or Tag, and then supply a Branch name or Tag name. Note that branch or tag names that contain forward slashes (/) are not supported.

      • In the Directory with source code field, specify the path within the repository where the function is defined. The path must point to the directory where your source files are located—see Structuring source code for more information. Use / if the function is defined directly in the root directory of a repository.

      • In the Function to execute field, type the name of your entrypoint function. This function must be available in your source file.

  7. Use the Runtime dropdown to select a runtime.

  8. Click More to display advanced options, such as setting a region, specifying a timeout, or adding environment variables.

When you finish these steps, your display should resemble the following, depending on which settings you selected:

Screenshot showing function creation form for Python

When you are satisfied with your settings, scroll down to the bottom of the page and click Create.

Deploy a function

After you click 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 deployment process

To redeploy a function, click its name to go to the Function details page, and click Edit. When you're done making changes, click Save. This redeploys your function with a new version number.

Cette page vous a-t-elle été utile ? Évaluez-la :

Envoyer des commentaires concernant…

Cloud Functions Documentation