# Create Cloud Function in GCP

In 
GCP
Published 2022-12-03

This tutorial explains how we can create a Cloud Function in GCP.

Cloud Functions is a lightweight, event-based, asynchronous compute solution that allows you to create small, single-purpose functions that respond to cloud events - without the need to manage a server or a runtime environment.

With Cloud Functions, there are no servers to provision, manage, patch, or update. Functions automatically scale and are highly available and fault-tolerant.Cloud Functions are great for building serverless backends, doing real-time data processing, and creating intelligent apps.

Cloud Functions are priced according to how long your function runs, how many times it is invoked and how many resources you provision for the function. If your function makes an outbound network request, there are also additional data transfer fees. Cloud Functions includes a perpetual free tier for invocations to allow you to experiment with the platform at no charge. Note that even for free tier usage, we require a valid billing account.

Cloud Functions (2nd gen) pricing is based on Cloud Run pricing.

For creating a Cloud Function, we need to connect to the console and go to "Serverless" -> "Cloud Functions".

You will see something like this:

Click on "Create Function".

Choose the environment type to use, function name, the region where the function will be created, and the trigger for that function. In my case, the trigger will be an HTTP request and I use "2nd gen" environment.

Choose the authentication you need.

Click on "Next".

Enter the runtime environment, the Entry Point and the function itself.

Here we have the code of my function:

const functions = require('@google-cloud/functions-framework');

functions.http('helloHttp', (req, res) => {
 
 myMessage="Hello "+req.query.name +" from GCP";

 res.send(`${myMessage}`);
});

Now we can run https://function-1-sue6hk2rka-uc.a.run.app?name=John in the browser and we will see :