- Andreas Bartel
- November 17, 2021
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.
- Click on Create function.
- Provide the cloud function name.
- Select Region.
- At Trigger field, select HTTP.
- Click on Save.
- Then click on Runtime.
- 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.
- At Build click on Add variable.
- Provide the Name & value for Build environment variable.
- Click on Connections.
- At connection settings set the Traffic rules.
- Click on Next.
- Select the Runtime such as Node.js 10, java11,python 3.7 or php 7.4.
- Click on Source code.
- 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.
- After sometime Deployment is done then go to cloud function page.
Test the function
- In the Actions field click Test function.
- On the testing page click Test the function.
- Then output will be display on screen.