Stay organized with collections Save and categorize content based on your preferences.
Deploy a functionThis guide shows you how to deploy a function from source code using the gcloud functions
command. To learn how to deploy a function using the gcloud run
command, see Deploy a Cloud Run function using the gcloud CLI.
The deployment process takes your source code and configuration settings and builds a runnable image that Cloud Run functions manages automatically in order to handle requests to your function.
Deployment basicsFor an introduction on the type of functions you can deploy, see Write Cloud Run functions.
Users deploying functions must have the Cloud Functions Developer IAM role or a role that includes the same permissions. See also Additional configuration for deployment.
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
Use the gcloud functions deploy
command to deploy a function:
gcloud functions deploy YOUR_FUNCTION_NAME \ --region=YOUR_REGION \ --runtime=YOUR_RUNTIME \ --source=YOUR_SOURCE_LOCATION \ --entry-point=YOUR_CODE_ENTRYPOINT \ TRIGGER_FLAGS
The first argument, YOUR_FUNCTION_NAME
, is a name for your deployed function. The function name must start with a letter followed by up to 62 letters, numbers, hyphens, or underscores, and must end with a letter or a number. The name of the Cloud Run service that is created for your function will replace underscores with hyphens and uppercase letters will be converted to lowercase. For example, Function_1
will be given the name function-1
in Cloud Run.
gcloud config set functions/gen2 true
to set all future first time deployments.
The --region
flag specifies the region in which to deploy your function. See Locations for a list of regions supported by Cloud Run.
The --runtime
flag specifies which language runtime your function uses. See Runtime support for a list of supported runtime IDs.
The --source
flag specifies the location of your function source code.
The --entry-point
flag specifies the entry point to your function in your source code. This is the code that will be executed when your function runs. The value of this flag must be a function name or fully-qualified class name that exists in your source code. For more information, see Function entry point.
To specify the trigger for your function, additional flags (represented as TRIGGER_FLAGS
above) are required, depending on the trigger you want to use:
--trigger-http
Trigger the function with an HTTP(S) request. --trigger-topic=YOUR_PUBSUB_TOPIC
Trigger the function when a message is published to the specified Pub/Sub topic. --trigger-bucket=YOUR_STORAGE_BUCKET
Trigger the function when an object is created or overwritten in the specified Cloud Storage bucket. --trigger-event-filters=EVENTARC_EVENT_FILTERS
Trigger the function with Eventarc when an event that matches the specified filters occurs.
For a complete reference on the deployment command and its flags, see the gcloud functions deploy
documentation.
For more details about gcloud functions deploy
configuration flags, refer to Cloud Run documentation.
When deployment finishes successfully, functions appear with a green check mark in the Cloud Run overview page in the Google Cloud console.
The initial deployment of a function may take several minutes, while the underlying infrastructure is provisioned. Redeploying an existing function is faster, and incoming traffic is automatically migrated to the newest version.
Note: Instances provisioned with a previous version of a function may continue running and processing traffic for several minutes after a new deployment has finished. This ensures that traffic sent to your function while a deployment is in progress isn't dropped. Also note that when a deployment fails, if there is a previous version of the function, it will continue to be available in most cases. HTTP endpoint URLWhen you create a function with the gcloud functions
command or the Cloud Functions v2 API, by default, the function has a cloudfunctions.net
HTTP endpoint URL. If you take this function and deploy it on Cloud Run, your function also receives a run.app
HTTP endpoint URL. However, functions created in Cloud Run won't have an cloudfunctions.net
HTTP endpoint URL. A function's cloudfunctions.net
URL and run.app
URL behave in exactly the same way. They are interchangeable, and are used to trigger your function.
For examples about how to deploy functions using Terraform, see the Terraform HTTP example and Terraform Pub/Sub example.
Configure networkingFunctions created using the Cloud Functions v2 API (for example, by using gcloud functions
, the REST API, or Terraform) can be managed with the Cloud Run Admin API as well as the Cloud Functions v2 API.
gcloud run
commands or the Cloud Run Admin API, you can't manage that function with gcloud functions
commands or the Cloud Functions v2 API.
To learn more about managing networks for functions, including how to route VPC network traffic, see Best practices for Cloud Run networking.
Learn how to deploy Cloud Run functions on Cloud RunDeploying functions on Cloud Run is similar to the steps described in this document, but with some added advantages:
gcloud run deploy
).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 guide outlines how to deploy a Cloud Run function from source code, which involves building a runnable image automatically managed by Cloud Run to handle requests."],["Deployment requires the Cloud Functions Developer IAM role or equivalent permissions and can be initiated using the `gcloud functions deploy` command in Cloud Shell, specifying details like function name, region, runtime, source location, and entry point."],["Functions can be triggered by HTTP requests, Pub/Sub messages, Cloud Storage events, or Eventarc events, each requiring specific trigger flags in the deployment command."],["Source code for deployment can be located on your local machine or in a Cloud Storage bucket, with the latter requiring the Cloud Run functions service agent to have `storage.objects.get` permission."],["The initial deployment of a function can take several minutes, while redeployments are faster, and the deployment process also includes excluding unnecessary files through the `.gcloudignore` 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