How to Create Cloud Function in Google Cloud Platform

Google Cloud Functions is a serverless execution environment for building and connecting cloud services. With Cloud Functions you write simple, single-purpose functions that are attached to events emitted from your cloud infrastructure and services.

Cloud Functions can respond to events from Google Cloud services such as Cloud Storage, Pub/Sub, and Cloud Firestore to process files immediately after upload and generate thumbnails from image uploads, process logs, validate content,validate, aggregate, and filter data in real time.

 

  • Login to google cloud platform.
  • Click on cloud functions.

 

Fig 1

 

 

  • Click on Create function.

 

Fig 2

 

  • Provide the cloud function name.
  • Select Region.

 

Fig. 3

 

  • At Trigger field, select HTTP.
  • Click on Save.
  • Then click on Runtime.

 

Fig. 4

 

  • In the runtime field provide the memory allocated and timeout(in seconds).
  • Provide the max number of instances for autoscaling.
  • Click on Add variables.
  • Provide key & value for runtime environment variable.
  • Then click on Build.

 

Fig. 5

 

  • At Build click on Add variable.
  • Provide the Name & value for Build environment variable.
  • Click on Connections.

 

Fig. 6

 

  • At connection settings set the Traffic rules.
  • Click on Next.

 

Fig. 7

 

  • Select the Runtime such as Node.js 10, java11,python 3.7 or php 7.4.
  • Click on Source code.

 

Fig. 8

  • At source code we can write a code and upload a zip file from cloud storage or upload from cloud source repository.
  • Click on Deploy.

 

Fig. 9

 

  • After sometime Deployment is done then go to cloud function page.

 

Fig. 9

Test the function

  • In the Actions field click Test function.

 

Fig. 11

 

  • On the testing page click Test the function.
  • Then output will be display on screen.

 

Leave a Reply