If you're interested in learning about Cloud Functions but prefer your education in a more audio-visual format, this series of videos from the Firebase YouTube channel might be of interest to you.
To get started with Cloud Functions, watch these first three videos, which cover basic topics like deployment, event triggers, and asynchronous programming.
Getting Started with Cloud Functions
This tutorial walks you through all of the initial steps required in creating and deploying your very first function.
- What are Cloud Functions?
- Installing prerequisites
- Initializing Cloud Functions within your project
- Deploying a basic function
- Viewing logs
Writing a Realtime Database Trigger
This tutorial shows you how to create a function that runs code in response to changes that happen in the Realtime Database.
- Writing a Realtime Database trigger
- Understanding the event object
- Returning a promise
- Preventing infinite loops
Asynchronous Programming (I Promise!)
- Why do we need promises?
- Basic use of a promise
- Chaining promises
- Using Promise.all() for multiple tasks
More about event triggers
Cloud Functions can be used to respond to a variety of events triggered by Cloud Storage, Authentication, or other events that might happen on the server. These next few videos show you how to build functions in response to some of the more common triggers. Feel free to jump to the video topic that's of most interest to you.
Writing a Cloud Storage Trigger (Part 1)
This tutorial shows you how to write Cloud Functions to respond to changes in Cloud Storage, such as when a new photo is uploaded.
- Why use a Cloud Storage trigger?
- Setting up project dependencies
- How Cloud Storage triggers work
- Writing the function
- Preventing infinite loops when writing back to Cloud Storage
Writing a Cloud Storage Trigger (Part 2)
This tutorial builds on the function created in the previous video to save the download URLs of the newly created thumbnail image to the Realtime Database.
- Using Service Account Credentials for Cloud Storage
- Setting up the Firebase Admin SDK
- Generating a signed URL for objects in Cloud Storage
- Writing data back to the Realtime Database
- Using the
gsutilfrom the command line to test and trigger Cloud Functions
Writing an Authentication Trigger
This video walks through how to bootstrap a user profile in the Realtime Database when a new user is created.
- Writing the authentication trigger
- Accessing user properties from within the function
- Responding to user deletion events
Once you've gotten comfortable with asynchronous programming and responding to triggers, you can go through some other videos that cover more advanced topics.
Simulating Cron Jobs using an HTTP Trigger and Cron
This tutorial shows how to use an HTTP trigger with Cloud Functions for Firebase, and how to use a cron job to time when the function gets triggered.
- Options for scheduling cron jobs
- Writing an HTTP trigger
- Using nodemailer to send an email
- Scheduling the function using cron-job.org