Stay organized with collections Save and categorize content based on your preferences.
This page shows you how to create, download, deploy, and invoke a 2nd gen HTTP function using Cloud Functions with Cloud Code.
Before you beginIn the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Functions, Cloud Build, Artifact Registry, Cloud Run, Logging, and Pub/Sub APIs.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Functions, Cloud Build, Artifact Registry, Cloud Run, Logging, and Pub/Sub APIs.
If you've created a function before, you can download an existing function to a new workspace and edit it locally.
To create a new function using a sample, follow these steps:
Click Cloud Code and then expand the Cloud Functions section.
Click add Create function and select a template.
Navigate to the pathway that you'd like to create your new function in, enter a name for the function, and select Create New Application.
If the folder of your application doesn't appear automatically in the Explorer, click refresh Refresh.
The launch.json
file contains the required configurations for your function:
{
"configurations": [
{
"name": "Deploy Cloud Function",
"type": "cloudcode.cloudfunctions",
"request": "launch",
"functionName": "function-hello-world",
"gen": "GEN_2",
"entryPoint": "helloHttp",
}
]
}
To learn more about creating multiple functions in a single workspace, see Manage functions in VS Code workspace.
Download an existing function to a new workspaceTo download a function to a new workspace, follow these steps:
Click Cloud Code and then expand the Cloud Functions section.
Expand your Google Cloud project snippet, right-click the function that you wish to download, and select Download to new workspace.
When prompted, enter a name for the new application and click Create New Application.
This downloads the function to your local machine and opens it in a new workspace in your IDE.
To deploy a function, follow these steps:
Right-click a function and select Deploy function.
In the Quickpick menu, select a Google Cloud project to deploy your function to.
Select a region that the function will be deployed to.
Select a runtime.
The function's deployment may take a few minutes. While in progress, a progress_activity progress indicator appears. After it is complete, a check_circle checkmark appears. If it fails, an error error mark appears.
If the deployment fails, refer to the Output tab for the error message. Clicking the link takes you to the build logs in Google Cloud console and provides more detail about the error.
Optional: Once the function is deployed, you can perform the following actions:
To view read-only files of your deployed function, expand the function and then expand the Source Code folder. Here you can view launch.json
under .vscode
, the deployed code, and package.json
.
To view the function in Google Cloud console, right-click the function and select Open in Cloud Console, and if prompted, select Open.
To edit the metadata of your function, right-click the function and select Edit metadata in Cloud Console.
To view logs of the deployed function, right-click the function and select View logs.
Invoking a function allows you to execute the deployed function in Google Cloud console from the IDE's built-in terminal. To invoke a function, follow these steps:
Right-click the function and select Invoke function via HTTP.
In the Trigger function via HTTP Quickpick that appears, select one of the two options:
Default: A terminal opens in the IDE and runs a command to execute the function in Google Cloud.
Import arguments from JSON file: This option takes the content of the selected JSON file, turns it into a string, and passes it with -d '{
. This is useful for when you have an input to your functions and want to save it, allowing you to execute it without having to retype it repeatedly.
To send feedback, report issues on
GitHub, or ask a question on
Stack Overflow.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This page guides users on how to manage 2nd gen HTTP functions using Cloud Functions with Cloud Code, covering creation, downloading, deployment, and invocation."],["New functions can be created from templates within Cloud Code, allowing users to define function names and create new applications within specified pathways."],["Existing functions can be downloaded from Google Cloud to a new workspace on a local machine, allowing users to then edit locally."],["Functions are deployed to a user-specified Google Cloud project, region, and runtime, with progress indicators and options to view source code, logs, or edit metadata."],["Deployed functions can be invoked directly from the IDE via HTTP, either with default settings or by importing arguments from a JSON file."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4