Quickstart: Deploy a function to Cloud Run using the Google Cloud console
This page shows you how to use Cloud Run to deploy an HTTP function using the Google Cloud console.
Before you begin
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry, Cloud Build, Cloud Run Admin API, and Cloud Logging APIs.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry, Cloud Build, Cloud Run Admin API, and Cloud Logging APIs.
If you are under a domain restriction organization policy restricting unauthenticated invocations for your project, you will need to access your deployed service as described under Testing private services.
- For Cloud Build to be able to build your sources, grant the
Cloud Build Service Account
role to the Compute Engine default service account by running the following:
gcloud projects add-iam-policy-binding PROJECT_ID \ --member=serviceAccount:PROJECT_NUMBER-compute@developer.gserviceaccount.com \ --role=roles/cloudbuild.builds.builder
Replace
PROJECT_NUMBER
with your Google Cloud project number, andPROJECT_ID
with your Google Cloud project ID. For detailed instructions on how to find your project ID, and project number, see Creating and managing projects.Granting the Cloud Build Service Account role to the Compute Engine default service account takes a couple of minutes to propagate.
Deploy the function
Important: This quickstart assumes that you have owner or editor roles in the project you are using for the quickstart. Otherwise, refer to the Cloud Run Source Developer role for the required permissions for deploying a Cloud Run resource from source.
To deploy a function, follow these steps:
In the Google Cloud console, go to the Cloud Run page:
Click Write a function.
In the Service name field, enter a service name to describe your function, such as
my-nodejs-http-function
. Service names must only begin with a letter, and contain up to 49 characters or less, including letters, numbers, or hyphens. Service names can't end with hyphens, and must be unique per region and project. A service name cannot be changed later and is publicly visible.In the Region list, use the default value
us-central1
, or select the region where you want to deploy your function.In the Runtime list, use the default value, or select a runtime version.
In the Authentication section, select Allow unauthenticated invocations. If you don't have permissions (Cloud Run Admin role) to select this, the service will deploy and require authentication.
Click Create, and wait for Cloud Run to create the service using a placeholder revision.
The console will redirect you to the Source tab where you can see the source code of your function. Click Save and redeploy.
In the Source tab, you can optionally click Show Payload to see the incoming request object.
After deployment, the container's URL is displayed next to the text URL:. To view the output of the function, click
Copy to clipboard to copy its URL, and paste the URL into your browser's address bar.
To learn how to add Eventarc triggers to your function, see the Deploy a function guide for instructions.
Cloud Run locations
Cloud Run is regional, which means the infrastructure that
runs your Cloud Run services is located in a specific region and is
managed by Google to be redundantly available across
all the zones within that region.
Meeting your latency, availability, or durability requirements are primary
factors for selecting the region where your Cloud Run services are run.
You can generally select the region nearest to your users but you should consider
the location of the other Google Cloud
products that are used by your Cloud Run service.
Using Google Cloud products together across multiple locations can affect
your service's latency as well as cost.
Cloud Run is available in the following regions:
Subject to Tier 1 pricing
asia-east1
(Taiwan)asia-northeast1
(Tokyo)asia-northeast2
(Osaka)asia-south1
(Mumbai, India)europe-north1
(Finland) Low CO2europe-southwest1
(Madrid) Low CO2europe-west1
(Belgium) Low CO2europe-west4
(Netherlands) Low CO2europe-west8
(Milan)europe-west9
(Paris) Low CO2me-west1
(Tel Aviv)us-central1
(Iowa) Low CO2us-east1
(South Carolina)us-east4
(Northern Virginia)us-east5
(Columbus)us-south1
(Dallas) Low CO2us-west1
(Oregon) Low CO2
Subject to Tier 2 pricing
africa-south1
(Johannesburg)asia-east2
(Hong Kong)asia-northeast3
(Seoul, South Korea)asia-southeast1
(Singapore)asia-southeast2
(Jakarta)asia-south2
(Delhi, India)australia-southeast1
(Sydney)australia-southeast2
(Melbourne)europe-central2
(Warsaw, Poland)europe-west10
(Berlin) Low CO2europe-west12
(Turin)europe-west2
(London, UK) Low CO2europe-west3
(Frankfurt, Germany) Low CO2europe-west6
(Zurich, Switzerland) Low CO2me-central1
(Doha)me-central2
(Dammam)northamerica-northeast1
(Montreal) Low CO2northamerica-northeast2
(Toronto) Low CO2southamerica-east1
(Sao Paulo, Brazil) Low CO2southamerica-west1
(Santiago, Chile) Low CO2us-west2
(Los Angeles)us-west3
(Salt Lake City)us-west4
(Las Vegas)
If you already created a Cloud Run service, you can view the region in the Cloud Run dashboard in the Google Cloud console.
Clean up
While Cloud Run does not charge when the service is not in use, you might still be charged for storing the container image in Artifact Registry. You can delete your container image or delete your Google Cloud project to avoid incurring charges. Deleting your Google Cloud project stops billing for all the resources used within that project.
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
What's next
To deploy a sample function to Cloud Run using the Google Cloud CLI, see Quickstart: Deploy a function to Cloud Run using the gcloud CLI.
To deploy functions using the Google Cloud console and the Google Cloud CLI, see Deploy functions.
To view and delete existing functions, see Manage service revisions.
To build function containers in your own toolchain and deploy it to Cloud Run, see Build functions.