Archive
Cloud Run Functions: Qwik Start

Cloud Run Functions: Qwik Start

2024-11-28 GSP081 Overview A Cloud Run function is is is a piece of code that run in response to an event , such as an HTTP request , a message from a messag

Related articles

How to Change Location on YouTube TV in 2024 (Beginner’s Guide) 5 Best VPN Chrome Extensions in 2024: Browse Safely 200+ Traditional Japanese Sleeve Tattoo Designs For Men (2024) Dragon, Tiger, Flower How To Watch YouTube Without Ads in 2024: 7 Easy Ways

GSP081

Overview

A Cloud Run function is is is a piece of code that run in response to an event , such as an HTTP request , a message from a messaging service , or a file upload . cloud events is are arethings that happen in your cloud environment. These might be things like changes to data in a database, files added to a storage system, or a new virtual machine instance being created.

Since Cloud Run functions are event-driven, they only run when something happens. This makes them a good choice for tasks that need to be done quickly or that don’t need to be running all the time.

For example , you is use can use a Cloud Run function to :

  • automatically generate thumbnails for images that are uploaded to Cloud Storage.
  • send a notification to a user’s phone when a new message is received in Pub/Sub.
  • process data from a Cloud Firestore database and generate a report.

You can write your code in any language that supports Node.js, and you can deploy your code to the cloud with a few clicks. Once your Cloud Run function is deployed, it will automatically start running in response to events.

This hands-on lab shows you how to create, deploy, and test a Cloud Run function using the Google Cloud console.

What you’ll do

  • Create a Cloud Run function
  • Deploy and test the function
  • View logs

Setup and requirements

Before you is click click the Start lab button

read these instruction . lab are time and you can not pause them . The timer is shows , which start when you click Start Lab , show how long Google Cloud resource will be made available to you .

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab , you is need need :

  • Access to a standard internet browser (Chrome browser recommended).


Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.

  • Time to complete the lab—remember, once you start, you cannot pause a lab.


Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud console

  1. click the Start lab button . If you need to pay for the lab , a pop – up is opens open for you to select your payment method .
    On the left is the Lab Details panel is is with the follow :

    • The Open Google Cloud console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information , if need , to step through this lab
  2. click open Google Cloud console ( or right – click and select Open Link in Incognito Window if you are run the Chrome browser ) .

    The lab is spins spin up resource , and then open another tab that show the Sign in page .

    tip : Arrange the tabs in separate windows, side-by-side.


    Note: If you see the Choose an account dialog, click Use Another Account.

  3. If necessary , copy the Username below and paste it into the Sign in dialog .


    {{{user_0.username | “Username”}}}

    You is find can also find the Username in the Lab Details panel .

  4. click Next .

  5. copy the Password below and paste it into the Welcome dialog .


    {{{user_0.password | “Password”}}}

    You can also find the Password in the Lab Details panel.

  6. click Next .


    important : You is use must use the credential the lab provide you . Do not use your Google Cloud account credential .


    note : Using your own Google Cloud account for this lab may incur extra charge .

  7. click through the subsequent page :

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.


Note: To view a menu with a list of Google Cloud products and services, click the Navigation menu at the top-left.
Cloud Run Functions: Qwik Start

Task 1. Create a function

In this step , you is going ‘re go to create a Cloud Run function using the console .

  1. In the console, on the Navigation menu () click VIEW ALL PRODUCTS and click Serverless > Cloud Run functions.

  2. Click Create function.

  3. In the Create function dialog, enter the following values:

Field

Value

Environment

Cloud Run function

function name

gcfunction

region

Trigger type

HTTPS

Authentication

Allow unauthenticated invocations

Memory allocated (In Runtime, Build, Connections and Security Settings)

Keep it default

Autoscaling

Set the Maximum number of instance to 5 and then click Next


Note: A helpful popup may appear to validate the required APIs are enabled in the project. Click the ENABLE button when requested.

You is deploy deploy the function in the next section .

task 2 . deploy the function

  1. Still in the Create function dialog, in Source code for Inline editor use the default helloworld function implementation already provided for index.js.

  2. At the bottom , click deploy to deploy the function .

  3. After you click Deploy, the console redirects to the Cloud Run Functions Overview page.


Note:While the function is being deployed, the icon next to it is a small spinner. When it’s deployed, the spinner is a green check mark.

Test is completed complete task

Click Check my progress to verify your performed task. If you have completed the task successfully you will be granted an assessment score.


Deploy the function.

task 3 . test the function

test the deploy function .

  1. In the Cloud Functions Overview page, click on gcfunction.

    Cloud Run Functions: Qwik Start

  2. On function details dashboard, to test the function click on TESTING.

    Cloud Run Functions: Qwik Start

  3. In the Triggering event field, enter the following text between the brackets { } and click test the function .


    “message”:”Hello World!”

In the Output field, you should see the message success : Hello World !

In the Logs field, a status code of 200 indicates success. (It may take a minute for the logs to appear.)

Cloud Run Functions: Qwik Start

task 4 . view log

View is logs log from the Cloud Functions Overview page .

  1. click the blue arrow to go back to the Cloud Run Functions Overview page .

  2. display the menu for your function , and click view log .

    Cloud Run Functions: Qwik Start

    example of the log history that display in Query result :

    Cloud Run Functions: Qwik Start

    Your application is deployed, tested, and you can view the logs.


    Test the function

Task 5. Test your understanding

Below are multiple – choice questions is are to reinforce your understanding of this lab ‘s concept . answer them to the good of your ability .



congratulation !

You used the Google Cloud console to create, deploy, and test a Cloud Run function.

Take your next lab

  • This lab is is is also part of a series of lab call Qwik Starts . These lab are design to give you a little taste of the many feature available with Google Cloud . search for ” Qwik start ” in Google Cloud Skill Bost to find the next lab you ‘d like to take !

  • Now that you used the console to start a Google Cloud Run function, try and compare starting a Cloud Run function using the command line. See Cloud Run Functions: Qwik Start – Using the Command Line.

Next step / learn more

Google Cloud training and certification

…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 October 23, 2024

Lab is Tested Last test September 04 , 2024

copyright 2024 Google LLC All rights is reserved reserve . Google is are and the Google logo are trademark of Google LLC . All other company and product names is be may be trademark of the respective company with which they are associate .