Scheduling Google Cloud Functions

Currently, there is no straightforward way to schedule Google Cloud Functions. It is still possible to achieve this by different means, such as (but not limited to):
- deploying Compute Engine instance and setting crontab entry
- configuring HTTP/S uptime checks via Stackdriver Monitoring
- deploying App Engine cron job
Compute Engine instance
Deploying separate Compute Engine instance just for this does not sound right. Also, to achieve High Availability, multiple instances have to be deployed, leading to each instance scheduling tasks independently of the others.Stackdriver Monitoring uptime check
Stackdriver Monitoring uptime checks are performed from all available locations, by default. There is a way to limit checks by one or more location, but some of them, US for example, have multiple regions from where the checks are performed. Again, the function will be iinvoked more often than required.App Engine cron job
App Engine cron job, on the other side, is one of the recommended ways to implement reliable cron functionality. It comes with its own limitations, such as App Engine cron job can only invoke App Engine endpoints, so an application needs to be deployed as well. By default, it will be deployed in High Availability setup, having 2 instances running.Implementing Cloud Function scheduling via App Engine cron job
When following instructions assume there is a Google Cloud Platform project namedtest-gcf-scheduling
and service account named
deployment
with Project Owner permissions created, and service account JSON key has been downloaded under
deployment-key.json
. Also, sample
code repository has been cloned into current working directory: [code language="bash"] git clone https://github.com/ilgarm/test-gcf-scheduling.git cd test-gcf-scheduling [/code] Authorize service account first and enable required services: [code language="bash"] gcloud config set project test-gcf-scheduling gcloud auth activate-service-account --key-file=test-gcf-scheduling-key.json gcloud services enable appengine gcloud services enable cloudfunctions [/code]