1. Enable Cloud Function API
First, we need to enable Cloud Function API. Go to “APIs & Services” From the left menu, click “Dashboard.”
Click on the “Enable APIS And Services” Button.
Now Search for “cloud functions” and select “Cloud Functions API” from the results.
Finally, click the “Enable” button.
You will be able to see API Dashboard after it’s being enabled.
2. Create a Cloud Function
Form GCP Left Services Menu select “Cloud Functions.”
The first time it will show a prompt, click on “Create Function”
Enter your function name, select the region, and set the way you want to trigger the function from “Trigger Type”.
Your Cloud Function can be triggered from different GCP services listed below in the following image, such as Pub/Sub, where it can be the worker for a Message-Queue, or it can be invoked using HTTP URL.
In the advanced section, you can set memory, timeout, and function environment variables.
Click “save” on the Trigger options section first to be able to deploy the function. Copy the “URL” to use in invoking the function
After deploying the function initial screen will show:
- Runtime options: Supported runtime languages
- Entry point: The function name in your code that will run on the cloud function triggered
- Source Code: You can use the inline Editor or upload Zip package code.
then click “deploy”.
Main Google Cloud Function limits are :
Max number of functions that can be deployed per region: 1000
Max deployment size : 100MB Compressed - 500MB uncompressed
Max function memory: 4096MB
Cloud Function provides a fast and way to deploy your serverless functions, requires an additional step to configure the security as part of GCP APIs, and provides a variety of runtimes.
Can be triggered by an HTTP Trigger, or Other GCP services, provides a fair web debugging console
7. Pros & Cons
Cloud Function Pros are the ease of setup, ease of integration with firebase and other GCP components e.g. GCP Pub/Sub. Comparing to other solutions it’s the only one FaaS with “Go Language” Runtime supported.
Doesn’t come with a scheduler like in IronWorker and it’s a FaaS solution with limitations on runtime unlike IronWorker a CaaS solution.
Google Cloud functions can be scheduled using “Google Cloud Scheduler”, GCP Pub/Sub more on scheduling here https://cloud.google.com/scheduler/docs/tut-pub-sub