GCP Classroom Series – 25/Apr/2021

Writing GCP Functions

  • There are two types of Cloud Functions
    • HTTP Functions: These are functions which are triggered by HTTP call
    • Event Driven functions:
      • They can be either background functions or Cloud Event Functions
  • Background Function:
    • We use background functions when you have your cloud function invoked as a response to event such as message in Pub/Sub topic or change in Cloud storage account
  • Cloud Event Function:
    • This is invoked directly in response to events. They are similar to background functions with the following differences
      • Cloud Event functions use an industry standard event format known as Cloud Events
      • CloudFunctions itself invokes Cloud Functions using HTTP requests, which can be reproduced else where

Setting up local dev environment for functions

  • Refer Here for setup
  • Python:
    • Install the functions-framework
    pip install functions-framework

HTTP Functions

  • Sample Usage
  • Refer Here for the sample code used
  • To connect to Cloud SQL from Cloud Functions Refer Here
  • Refer Here to use big table with cloud functions
  • Try to Create a simple Cloud Function in your favorite language and create a http request
curl -X POST gcpfunctionendpoint -H 'Content-Type:application/json' -d '{"name": "Khaja" }'
  • Write a Google cloud function to Shutdown all the vms with specific labels

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin