How to setup Google Cloud Scheduler job triggering your Cloud Function
In this story, we are covering how to setup google cloud scheduler job that triggers (HTTP) your cloud function with Authentication.
It allows you to schedule virtually any job, including batch, big data jobs, cloud infrastructure operations, and more. You can automate everything, including retries in case of failure. It allowing you to manage all your automation tasks from one place.
Let’s start,
Step 1 : In the Cloud Console, go to the Cloud Scheduler page:
Step 2 : Click Create Job.
Step 3: Set the name and description under “Define the schedule “
Name example,my-new-job
Step 4 : Set Frequency and Timezone.
Frequency example, */5 * * * *
It will run job every 5 minutes. The interval is defined using unix-cron format.
Timezone example, select United States and Los Angeles or Pacific Daylight Time (PDT).
Step 5 : Press Continue button
Step 6 : Select Target type as HTTP and paste cloud function URL then select HTTP method.
Step 7 : Set HTTP headers
For example, Name: User-Agent
and Value: Google-Cloud-Scheduler
Step 8 : Set Auth header, as OIDC token or OAuth token.
Enter the service account you previously created(it will in the credentials json file downloaded from cloud console)
For example, sa-name@PROJECT_ID.iam.gserviceaccount.com
Step 9 : Press Continue button
Step 10 : Configure the job’s retry (optional)
if you want retry , you can set its optional.
Step 11 : Hit Create button
The job will create and you can run ,test and view logs from dashboard.
By selecting view log, it will re-direct in to Logs Explorer and you can view logs by selecting specific time ranges.