Scheduling a Function
Find out how to schedule a function with OCI Functions.
For prerequisites and more information, see Scheduling Functions.
To schedule a function using the Resource Scheduler Console pages:
- Sign in to the Console as a functions developer.
- Open the navigation menu and click Governance & Administration. Under Resource Scheduler, click Schedules.
- Select the region you're using with OCI Functions.
We recommend that you use the same region as the Docker registry that's specified in the Fn Project CLI context. See Creating an Fn Project CLI Context to Connect to Oracle Cloud Infrastructure.
- Click Create a schedule to create a new resource schedule.
- On the Basic information page, specify the following values for the resource schedule:
- Schedule name: A name of your choice for the resource schedule. Avoid entering confidential information.
- Schedule description: (Optional) A meaningful description of the resource schedule.
- Action to be executed: Select Start.
- Show advanced options: Select this option to apply tags to the resource. If you have permissions to create a resource, then you also have permissions to apply free-form tags to that resource. To apply a defined tag, you must have permissions to use the tag namespace. For more information about tagging, see Resource Tags. If you're not sure whether to apply tags, skip this option or ask an administrator. You can apply tags later.
- Click Next.
- On the Resources page, select the function you want to schedule as follows:
- From the Resource selection method options, select the Static - apply schedule to specific resources option.
- In the Search and filter box, use the default filter (Compartment All) to search for resources in all compartments, or click Compartment to select a specific compartment in which to search for resources..
- In the Search and filter box, select Resource type.
- Select FunctionsFunction from the list of resource types (de-select any other resource types that are selected), and click Apply.
The functions in the compartment you selected are shown.
- Select the function you want to schedule.
- Click Next.
- On the Schedule page, specify when and how often you want the function to run, and when the resource schedule should start and end.
For more information about setting up a resource schedule, see Adding Schedule Information.
- Click Next.
- On the Review page, confirm the information you have entered, and click Create schedule to schedule the function.
The new resource schedule is shown on the Schedules page.
Having created the resource schedule and added a function to it, you have to create both a dynamic group that includes the resource schedule, and a policy statement that grants the dynamic group access to the function:
- Click on the name of the resource schedule that you just created, and make a note of the resource schedule's OCID.
For example,
ocid1.resourceschedule.oc1.phx.amaaaaaa3______owq
. -
Create a new dynamic group, as follows:
- Open the navigation menu and click Identity & Security. Under Identity, click Domains. Under Identity domain, click Dynamic groups.
- Follow the instructions in To create a dynamic group, and give the dynamic group a name (for example,
resource-scheduler-prod-dynamic-group
). -
Specify a rule for the dynamic group as follows:
ALL {resource.type='resourceschedule', resource.id='<resource-schedule-OCID>'}
where
<resource-schedule-OCID>
is the OCID of the resource schedule that you noted earlier.For example:
ALL {resource.type='resourceschedule', resource.id='ocid1.resourceschedule.oc1.phx.amaaaaaa3______owq'}
- Click Create Dynamic Group.
- Create a policy to grant the new dynamic group access to functions in OCI Functions, as follows:
- Open the navigation menu and click Identity & Security. Under Identity, click Policies.
- Follow the instructions in To create a policy, and give the policy a name (for example,
resource-scheduler-prod-dyn-grp-policy
). -
Specify a policy statement similar to the following:
Allow dynamic-group <dynamic-group-name> to manage functions-family in tenancy
where
<dynamic-group-name>
is the name of the dynamic group that you just created.For example:
Allow dynamic-group resource-scheduler-prod-dynamic-group to manage functions-family in tenancy
- Click Create to create the new policy.
The function is now invoked according to the resource schedule that you have defined in Resource Scheduler.
Use the Resource Scheduler resource-scheduler schedule create command and required parameters to schedule a function.
For more information, see Creating Schedules
For a complete list of flags and variable options for OCI CLI commands, see the Command Line Reference.
Use the Resource Scheduler CreateSchedule API to schedule a function.