Google Cloud: Working with Cloud Functions

Share At:

What Is Cloud Functions?

  • Cloud Function lets you deploy snippets of code (functions) written in a limited set of programming languages, to natively handle HTTP requests or events from many GCP sources.
  • Cloud Functions lets you establish triggers on a wide variety of events that can come from a variety of Cloud and Firebase products.
  • Cloud Functions are limited in respect to the libraries, languages, and runtimes supported.

How it is different from Cloud Run and App Engine?

  • Cloud Functions server instances handle requests in a serial manner, which is not configurable whereas Cloud Run instances handle requests in a parallel manner, and the level of parallelism is configurable.
  • Cloud Functions allow you to choose from a set of programming languages and runtimes that is not configurable without requiring that you do anything other than deploying your code whereas Cloud Run allows you to choose any kind of backend configuration, but it requires that you supply a docker configuration that creates the runtime environment (which is more work).
  • App Engine is more suitable for applications, which have numerous functionalities inter-related even unrelated with each other e.g. microservices, while cloud functions are more events based functions and perform some single-purpose action.
  • It is easy to replicate Cloud Functions on Google App Engine, but replicating an App Engine application on Cloud Functions would be complicated.

Lab Details:

  1. This lab walks you through GCP Cloud Functions
  2. We have already pre-configured a Virtual Machine called “whizlabs-cloud-function”
  3. You will be creating a Simple Cloud Function listing names of all the VM Instances in the Project ( In our case there is only one VM called — whizlabs-cloud-function).
  4. Region: us-central1

Creating a Cloud Function:

  1. Click on the hamburger icon on the top left corner
  2. Click on Cloud Functions.

3. Click on Create Function.

4. Enter the name of the function as whizlabs-list-instances.

5. Choose the region as us-central1

6. Select trigger type as HTTP.

7. Choose authentication as Allow unauthenticated invocations. This is for learning purposes, in real-time you should always use authentication.

8. Click on Save

9. Click on Next

10. Choose the run time as Python 3.7

11. Enter the entry point as main which is the name of the function which you will create in the next step.

12. Click on main.py from the left sidebar

13. Write down the code to list down the instances in the Project. Change the project ID assigned to you, keep the zone as ‘us-central1-a’. We already created a VM Instance at the start of the lab. You can get the below code from the Supporting Document named GCP Cloud Function Code.

14. Click on deploy to finally deploy your function

15. You can see your function after deploying.

16. Click on the function name

17. Select the Trigger tab

18. Click on the URL listed in the Trigger tab

19. You will see the listed VM Instance name whizlabs-cloud-function.

This Concludes our Tutorial for “Working with Cloud Functions”.

Happy Learning !!!


Share At:
0 0 votes
Article Rating
Subscribe
Notify of
guest
3 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Tài khon binance
12 days ago

Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://accounts.binance.com/vi/register?ref=V2H9AFPY

Реєстрація на Binance

Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

Торговля криптовалютой на gate io

Very nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

Back To Top

Contact Us