Learn How Easy It Is To Create a Serverless Function in Google Cloud (GCP)

Learn How Easy It Is To Create a Serverless Function in Google Cloud (GCP)

February 23, 2021 0 Comments
Learn How Easy It Is To Create a Serverless Function in Google Cloud (GCP)

On the Progress Corticon team, we love serverless technologies. This blog is the third in a series on serverless. If you are interested in AWS Lambda functions you can get started with this post on creating your first serverless/Lambda functions. Or if you are interested in Azure function you can get started with this post https://www.progress.com/blogs/how-to-create-your-first-serverless-functions-on-microsoft-azure

Your first GCP Function

If you do not have an account on GCP, you can simply create one for free. See https://cloud.google.com/free to get started.

Once you are logged into your account, click on the navigation menu at the top left:

menu

And scroll down to the “Compute” section and click on “Cloud Functions.”

Function

Then click create and enter a function name.


Creation form

Click on “Save” and later click on “Next”. You will now be on the code screen.

Code screen

Click “Deploy.” This may take a while. Wait until you see the green checkmark as in the following screen.

Green light

Once you get the green checkmark, click on the Actions and from the list that appears click on “Test Function.”

test action

This will lead to the following screen:

Test

Click on “TEST THE FUNCTION” button, and you will get the following result at the bottom of the screen:

result

Congratulations, you have now run your first Google Cloud function. However, we didn't pass any data to the function. In the next section, we will learn how to use data from the input event.

Click on “Test the Function” as we did earlier and enter a specific JSON payload like this:
{

    "message":  "this is my own data"

}

And click on run again.  We will get:

result with our own data

You should now look at the code and see how the sample accesses the message property and returns it as part of the result. Observe how the result is returned via the response object.

Note how there is no way to save the JSON payload or create multiple test payloads as we can in AWS Lambda. This is a bit annoying and we hope Google will soon fix this.

Congratulations, you have now run your first GCP function. As you can see it is very simple and you didn’t have to do anything to get a function that automatically scale based on the load and most importantly you did not need to provision and manage a set of servers to handle the load.

Thierry Ciot

Thierry Ciot

Thierry Ciot is a Software Architect on the Corticon Business Rule Management System. Ciot has gained broad experience in the development of products ranging from development tools to production monitoring systems. He is now focusing on bringing Business Rule Management to Javascript and in particular to the serverless world where Corticon will shine. He holds two patents in the memory management space.

Comments
Comments are disabled in preview mode.
Topics
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
More From Progress
ResourceImage_570x321 RITM0091321
Run Business Rules Where Decisions Are Made with Corticon.js
Read More
 
supercharge-the-velocity-of-your--net-business-rules-with-corticon-6232x131_resourceimage.png
Supercharge the Velocity of Your .NET Business Rules with Corticon 6
Read More
 
570x321__Top 7 Considerations Before Choosing a Chatbot for Your Enterprise
Top 7 Considerations Before Choosing a Chatbot for Your Enterprise
Read More