I’m trying to schedule this function to run every week on Monday at 00:05 AM.
But it doesn’t run at that time. Using @scheduler_fn.on_schedule
has no effect on my function.
@https_fn.on_request()
@scheduler_fn.on_schedule(
schedule="5 0 * * 0",
timezone=scheduler_fn.Timezone("Europe/Bucharest")
)
def scheduleFunction(req: https_fn.Request) -> https_fn.Response:
1
According to the official documentation regarding writing a scheduled function using Cloud Functions 2nd gen, you should only add a single annotation, which is @scheduler_fn
. So assuming that you already added the import from firebase_functions import scheduler_fn
, the code should look like this:
from firebase_functions import scheduler_fn
@scheduler_fn.on_schedule(
schedule="every monday 00:05",
timezone=scheduler_fn.Timezone("Europe/Bucharest")
)
While the AppEngine syntax for scheduling the function every week, on Monday that exists in your code might work, please note that it’s easier to use every monday 00:05
.
Going forward, according to the same docs, the argument that should be passed to the scheduleFunction
function should be of type ScheduledEvent and not of type Request, as you currently pass.
1