⏱ Scheduling Firebase Cloud Functions with Cloud Scheduler

Pascal Luther
4 min readJan 13, 2019

I recently came across the use case where I needed to schedule a Firebase Cloud Function on a daily basis. I wanted a function that sends an email to my users via Amazon SES every night. A very common use case I’d say.

Since Firebase does not provide a scheduling functionality for its functions (yet), you need to find some other way to schedule a function. And there is a very easy way offered by Google itself: The Google Cloud Scheduler.

So let’s get started.

I am assuming that you already have a cloud function you call via your app manually (as described here), like the one below:

exports.sendEmail = functions.https.onCall((data, context) => {
// sending the email
})

Now that probably works well for you, but we want to call this function regularly and automatically.

Step 1 — Set up a Cloud Scheduler Job

So let’s hop over to your Google Cloud Platform console (which you can access with the same account you use Firebase) and then go to the Cloud Scheduler here.

Off-Topic:
@CodingDoug from the Firebase team just released an awesome and very insightful article about the relationship between Firebase and Google Cloud Platform, check it out here.

--

--

Pascal Luther

Cloud Product Architect by day, recreational web-developer by night. Currently a big fan of Vue & Nuxt.js and of going serverless with Google Firebase.