Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create an HTTP function
/ 10
Create a Cloud Storage function
/ 10
Create a Cloud Audit Logs function
/ 10
Create a VM instance
/ 10
Deploy different revisions
/ 20
Set up minimum instances
/ 20
Create a function with concurrency
/ 20
Create an HTTP function
/ 10
Create a Cloud Storage function
/ 10
Create a Cloud Audit Logs function
/ 10
Create a VM instance
/ 10
Deploy different revisions
/ 20
Set up minimum instances
/ 20
Create a function with concurrency
/ 20
Cloud Run functions is Google Cloud's Functions-as-a-Service offering. It comes with an advanced feature set and is powered by Cloud Run and Eventarc, giving you more advanced control over performance and scalability, and more control around the functions runtime and triggers from over 90+ event sources.
In this lab, you create Cloud Run functions that respond to HTTP calls, and get triggered by Cloud Storage events and Cloud Audit Logs. You also deploy multiple revisions of a Cloud Run function and explore new settings.
This new version of Cloud Run functions provides an enhanced FaaS experience powered by Cloud Run, Cloud Build, Artifact Registry, and Eventarc.
In this lab, you learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud, in Google Cloud, refer to the gcloud CLI overview guide.
Before you create the Cloud Run functions, you need to enable the relevant APIs.
You can use Gemini Code Assist in an integrated development environment (IDE) such as Cloud Shell to receive guidance on code or solve problems with your code. Before you can start using Gemini Code Assist, you need to enable it.
Click Cloud Code - No Project in the status bar at the bottom of the screen.
Authorize the plugin if necessary. If a project is not automatically selected, click Select a Google Cloud Project, and choose
Verify that your Google Cloud project (
For the first function, you create an authenticated Node.js function that responds to HTTP requests, and use a 10 minute timeout to showcase how a function can have more time to respond to HTTP requests.
Click the Open Editor button on the toolbar of Cloud Shell.
Add the following code to the hello-http/index.js file that simply responds to HTTP requests:
hello-http/package.json file to specify the dependencies.In the file Explorer, open the index.js file. This action enables Gemini Code Assist, as indicated by the presence of the icon in the upper-right corner of the editor.
Click the Gemini Code Assist: Smart Actions icon and select Explain this.
Gemini Code Assist opens a chat pane with the prefilled prompt of Explain this. In the inline text box of the Code Assist chat, replace the prefilled prompt with the following, and click Send:
Detailed explanations for the index.js and package.json code appears in the Gemini Code Assist chat.
y for the unauthenticated invocations pop-up:permissions error, please wait a few minutes and try the deployment again. It takes a few minutes for the APIs to be enabled.
Although not strictly necessary for this step, there is a timeout of 600 seconds. This allows the function to have a longer timeout to respond to HTTP requests.
You should see the following message as a response:
Click Check my progress to verify the objective.
In this section, you create a Node.js function that responds to events from a Cloud Storage bucket.
pubsub.publisher IAM role to the Cloud Storage service account:Click the Open Editor button on the toolbar of Cloud Shell.
Add the following code to the hello-storage/index.js file that simply responds to Cloud Storage events:
hello-storage/package.json file to specify the dependencies:In the file Explorer, open the index.js file within the "hello-storage" folder. This action enables Gemini Code Assist, as indicated by the presence of the icon in the upper-right corner of the editor.
Click the Gemini Code Assist: Smart Actions icon and select Explain this.
Gemini Code Assist opens a chat pane with the prefilled prompt of Explain this. In the inline text box of the Code Assist chat, replace the prefilled prompt with the following, and click Send:
Detailed explanations for the index.js and package.json code appears in the Gemini Code Assist chat.
permissions error, please wait a few minutes and try the deployment again. It can take a few minutes for the APIs to be enabled.
You should see output similar to the following.
Output:
Click Check my progress to verify the objective.
In this section, you create a Node.js function that receives a Cloud Audit Log event when a Compute Engine VM instance is created. In response, it adds a label to the newly created VM, specifying the creator of the VM.
Compute Engine emits 2 Audit Logs when a VM is created.
The first one is emitted at the beginning of the VM creation and looks like this:
The second one is emitted after the VM creation and looks like this:
Notice the operation field with the first: true and last: true values. The second Audit Log contains all the information you need to label an instance, therefore you use the last: true flag to detect it in Cloud Run functions.
To use Cloud Audit Log functions, you must enable Audit Logs for Eventarc. You also need to use a service account with the eventarc.eventReceiver role.
resourcemanager.folders.getIamPolicy permission warning.
Find the Compute Engine API and click the checkbox next to it. If you are unable to find the API, search for it on the next page.
On the info pane on the right, select the checkboxes for the Admin Read, Data Read, and Data Write log types, then click Save.
eventarc.eventReceiver IAM role:Click the Open Editor button on the toolbar of Cloud Shell.
In the file Explorer, navigate to eventarc-samples > gce-vm-labeler > gcf > nodejs > index.js.
Open the index.js file. This action enables Gemini Code Assist, as indicated by the presence of the icon in the upper-right corner of the editor.
Click the Gemini Code Assist: Smart Actions icon and select Explain this.
Gemini Code Assist opens a chat pane with the prefilled prompt of Explain this. In the inline text box of the Code Assist chat, replace the prefilled prompt with the following, and click Send:
The index.js file contains the application code that receives the Audit Log wrapped into a CloudEvent. It then extracts the Compute Engine VM instance details and sets a label on the VM instance. Feel free to study index.js in more detail on your own.
Detailed explanations for the index.js code appears in the Gemini Code Assist chat.
gcloud as before. Notice how the function is filtering on Audit Logs for Compute Engine insertions with the --trigger-event-filters flag:Click Check my progress to verify the objective.
To test your Audit Log function, you need to create a Compute Engine VM in the Cloud console. (You can also create VMs with gcloud but it does not seem to generate Audit Logs.)
From the Navigation menu, go to Compute Engine > VM instances.
Click Create Instance, set the instance Name as instance-1 and the Zone as
Leave all of the other fields as their defaults and click Create.
Once the VM creation completes, you should see the added creator label on the VM in the Cloud console in the Basic information section.
You should see the label in the output like in the following example.
Output example:
Click Check my progress to verify the objective.
Y, when prompted, to confirm.Cloud Run functions supports multiple revisions of your functions, splitting traffic between different revisions, and rolling your function back to a prior version. In this section, you deploy two revisions of your Cloud Run function.
hello-world-colored/main.py file with a Python function that reads a color environment variable and responds with Hello World in that background color:At this point, if you test the function by viewing the HTTP trigger (the URI output of the previously executed deployment command) in your browser, you should see Hello World with an orange background:
Navigate to the Cloud Run functions page, you are redirected to the Cloud Run console; click the hello-world-colored function.
Click Edit & Deploy New Revision.
Leave everything as their defaults, scroll down, select the Variables & Secrets tab. In the Environment Variables section, update the COLOR environment variable to yellow.
Since this is the latest revision, if you test the function, you should see Hello World with a yellow background:
Click Check my progress to verify the objective.
In Cloud Run functions, one can specify a minimum number of function instances to be kept warm and ready to serve requests. This is useful in limiting the number of cold starts. In this section, you deploy a function with slow initialization. You observe the cold start problem. Then, you deploy the function with the minimum instance value set to 1 to get rid of the cold start.
min-instances/main.go file. This Go service has an init function that sleeps for 10 seconds to simulate a long initialization. It also has a HelloWorld function that responds to HTTP calls:min-instances/go.mod file. This specifies the module path and Go language version:You should observe a 10 second delay (cold start) on the first call and then see the message. Subsequent calls should return immediately.
To get rid of the cold start on the first request, redeploy the function with the --min-instances flag set to 1 as follows:
Navigate to the Cloud Run page in the console and click the slow-function service.
Click Edit & Deploy New Revision.
Under the Revision scaling section, set Minimum number of instances to 1 and Maximum number of instances to 4.
Leave the rest of the fields as their defaults and click Deploy.
You should not see the 10 second delay anymore in the first request. The cold start problem for the first invocation (after a long time without) is gone, thanks to minimum instances! Refer to the using minimum instances documentation for more information.
Click Check my progress to verify the objective.
In Cloud Run functions, a function instance handles one concurrent request by default but you can specify the number of concurrent requests that can be processed simultaneously by an instance. This can also be useful in preventing cold starts because a new function instance does not need to be created for every parallel request.
In this section, you use the function with slow initialization from the previous step. You send it 10 requests and observe the cold start problem again as new function instances need to be created to handle the requests.
To fix the cold-start problem, you deploy another function with a concurrency value of 100. You observe that the 10 requests now do not cause the cold start problem and a single function instance can handle all of the requests.
hey in the Cloud Shell:hey to send 10 concurrent requests to the slow function.You should see in the output of hey that some requests are taking long.
Output:
This is because more function instances are being created to handle the requests. If you check the active instances count for the function, you should also see that more than one instance was created as some point and these are causing the cold start problem.
Y, when prompted, to confirm.Now you set the concurrency of the underlying Cloud Run service for the function to 100 (it can be a maximum of 1000). This ensures that at least 100 requests can be handled by a single function instance.
From the Navigation menu, go to Cloud Run.
Click the slow-concurrent-function service.
Click Edit & Deploy New Revision.
Under the Resources section, set the CPU to 1.
Under Requests, set the Maximum concurrent requests per instance to 100.
Under Revision scaling, set the Maximum number of instances to 4.
Leave the rest of the fields as their defaults and click Deploy.
hey to send 10 concurrent requests:You should see in the output of hey that all requests are processed quickly.
Output:
A single function instance was able to handle all the requests and the cold start problem is gone, thanks to the increased concurrency! Refer to the concurrency documentation for more information.
Click Check my progress to verify the objective.
In this lab, you deployed multiple Cloud Run functions that responded to HTTP calls, Cloud Storage events, and Cloud Audit Logs. You then deployed multiple revisions of the Cloud Run services running the functions and set concurrency values and got rid of cold starts with minimum instances.
For more information about Cloud Run functions, explore the following:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated November 12, 2025
Lab Last Tested November 12, 2025
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one
Complete this quick step to start your lab.