.NET - Schedule()
Creates a new Schedule to run a function on a defined frequency.
using Nitric.Sdk;using Nitric.Sdk.Function;Nitric.Schedule("send-reminder").Every(3, Frequency.Hours, context =>{// do some processingreturn context;});Nitric.Run();
Parameters
- Name
description
- Required
- Required
- Type
- string
- Description
The unique name of this Schedule within the app. Subsequent calls to
Schedule
with the same name will return the same object.
Notes
-
Schedules do not require access permissions to be specified.
-
Currently, local execution and testing of schedules is not supported.
-
You can directly test the functions that respond to scheduled triggers by sending HTTP requests to those functions with the same payload as defined in your schedule.
Coming Soon
- Local and manual testing of schedules is on our backlog to be completed soon.
Examples
Create a Schedule
using Nitric.Sdk;using Nitric.Sdk.Function;// Create a schedule that runs every 3 minutesNitric.Schedule("send-reminder").Every(3, Frequency.Minutes, context =>{// do some processingreturn context;});// Create a schedule that runs every 3 hoursNitric.Schedule("send-reminder").Every(3, Frequency.Hours, context =>{// do some processingreturn context;});// Create a schedule that runs every 3 daysNitric.Schedule("send-reminder").Every(3, Frequency.Days, context =>{// do some processingreturn context;});Nitric.Run();
Create a Schedule using Cron expression
using Nitric.Sdk;using Nitric.Sdk.Function;// Create a schedule that runs every 3 minutesNitric.Schedule("send-reminder").Cron("3 * * * *", context =>{// do some processingreturn context;});Nitric.Run();
Last updated on Jan 14, 2025