Stay organized with collections Save and categorize content based on your preferences.
This page explains how to deploy applications to Cloud Run functions using Cloud Build. If you're new to Cloud Build, read the quickstarts and the Build configuration overview first.
Cloud Run functions is a serverless execution environment for building and connecting cloud services. With Cloud Run 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. For more information on Cloud Run functions, read Cloud Run functions documentation.
Before you beginEnable the Cloud Run functions API:
Grant the Cloud Run functions Developer role to the Cloud Build service account:
In the Google Cloud console, go to the settings Cloud Build Permissions page:
Set the status of the Cloud Run functions Developer role to Enabled.
To run the gcloud
commands in this page, install the Google Cloud CLI.
Keep your application source code that you want to build and deploy to Cloud Run functions handy. Your source code needs to be stored in a repository, such as Cloud Source Repositories, GitHub, or Bitbucket.
Caution: Effective June 17, 2024, Cloud Source Repositories isn't available to new customers. If your organization hasn't previously used Cloud Source Repositories, you can't enable the API or use Cloud Source Repositories. New projects not connected to an organization can't enable the Cloud Source Repositories API. Organizations that have used Cloud Source Repositories prior to June 17, 2024 are not affected by this change.
Configuring the deploymentCloud Build enables you to use any publicly available container image to execute your tasks. You can do this by specifying the image in a build step
in the Cloud Build config file.
Cloud Run functions provides the gcloud functions deploy
command, which deploys your function from the directory containing your function code. You can use the cloud-sdk
image as a build step in your config file to invoke gcloud
commands within the image. Arguments passed to this build step are passed to Google Cloud CLI directly, allowing you to run any gcloud
command in this image.
To deploy an application to Cloud Run functions, use the following steps:
cloudbuild.yaml
or cloudbuild.json
.In the config file:
name
field and specify the gcloud
build step.functions deploy
to the args
field to invoke the gcloud functions deploy
command. For available configuration options, see gcloud functions deploy
reference.--source=.
implies that the source code is in the current working directory.
steps:
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
args:
- gcloud
- functions
- deploy
- FUNCTION_NAME
- --region=FUNCTION_REGION
- --source=.
- --trigger-http
- --runtime=RUNTIME
JSON
{
"steps": [
{
"name": "gcr.io/google.com/cloudsdktool/cloud-sdk",
"args": [
"gcloud",
"functions",
"deploy",
[
"FUNCTION_NAME"
],
"--region=FUNCTION_REGION",
"--source=.",
"--trigger-http",
"--runtime=RUNTIME"
]
}
]
}
Replace the placeholder values in the config file above with the following:
FUNCTION_NAME
is the name of the Cloud Run functions you are deploying. If you're updating an existing function, this value must match the name of the function you're updating.FUNCTION_REGION
is the region to which you're deploying Cloud Run functions. For a list of supported regions, see Cloud Run functions locations.--trigger-http
is the trigger type for this function, in this case an HTTP request (webhook).RUNTIME
is the runtime in which to run the function.For more information on using gcloud functions deploy
, see the Cloud Run functions documentation.
Start the build using the config file created in the previous step:
gcloud builds submit --region=REGION --config CONFIG_FILE_PATH SOURCE_DIRECTORY
Replace the placeholder values in the config file above with the following:
CONFIG_FILE_PATH
is the path to the build config file.SOURCE_DIRECTORY
is the path or URL to the source code.REGION
is one of the supported build regions.If you don't specify a CONFIG_FILE_PATH
and SOURCE_DIRECTORY
in the gcloud builds submit
command, Cloud Build assumes that the config file and the source code are in the current working directory.
You can automate the deployment of your software to Cloud Run functions by creating Cloud Build triggers. You can configure your triggers to build and deploy images whenever you update your source code.
To automate your deployment to Cloud Run functions:
In your repository root, add a config file with steps to invoke the gcloud functions deploy
command:
steps:
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
args:
- gcloud
- functions
- deploy
- FUNCTION_NAME
- --region=FUNCTION_REGION
- --source=.
- --trigger-http
- --runtime=RUNTIME
JSON
{
"steps": [
{
"name": "gcr.io/google.com/cloudsdktool/cloud-sdk",
"args": [
"gcloud",
"functions",
"deploy",
[
"FUNCTION_NAME"
],
"--region=FUNCTION_REGION",
"--source=.",
"--trigger-http",
"--runtime=RUNTIME"
]
}
]
}
Replace the placeholder values in the config file above with the following:
FUNCTION_NAME
is the name of the Cloud Run functions you are deploying. If you're updating an existing function, this value must match the name of the function you're updating.FUNCTION_REGION
is the region to which you're deploying Cloud Run functions. For a list of supported regions, see Cloud Run functions locations.--trigger-http
is the trigger type for this function, in this case an HTTP request (webhook).RUNTIME
is the runtime in which to run the function.Create a build trigger with the config file created in the previous step:
Open the Triggers page in the Google Cloud console:
Select your project from the project selector drop-down menu at the top of the page.
Click Create Trigger.
In the Name field, enter a name for your trigger.
Under Region, select the region for your trigger.
Note: The region for your trigger must match the region of the function you're deploying to.Under Event, select the repository event to start your trigger.
Under Source, select your repository and the branch or tag name that will start your trigger. For more information on specifying which branches to autobuild, see Creating a build trigger.
Under Configuration, select Cloud Build configuration file (YAML or JSON).
In the Cloud Build configuration file location field, type cloudbuild.yaml
after the /
.
Click Create to save your build trigger.
Anytime you push new code to your repository, you will automatically trigger a build and deploy on Cloud Run functions.
For more information on creating Cloud Build triggers, see Creating and managing build triggers.
What's nextExcept 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-15 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-15 UTC."],[[["This page provides instructions on deploying applications to Cloud Run functions using Cloud Build, a service for executing tasks through publicly available container images."],["To deploy an application, a Cloud Build configuration file (`cloudbuild.yaml` or `cloudbuild.json`) must be created, specifying the `gcloud functions deploy` command within the `cloud-sdk` image."],["Continuous deployment to Cloud Run functions can be automated by creating Cloud Build triggers that monitor a specified repository for code updates."],["Before deploying, you must enable the Cloud Run functions API and grant the Cloud Build service account the Cloud Run functions Developer role."],["The source code you want to deploy needs to be stored in a repository such as Cloud Source Repositories, GitHub, or Bitbucket, but new customers will not have access to the Cloud Source Repositories as of June 17, 2024."]]],[]]
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