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:

    1. Sign in to the Console as a functions developer.
    2. Open the navigation menu and click Governance & Administration. Under Resource Scheduler, click Schedules.
    3. 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.

    4. Click Create a schedule to create a new resource schedule.
    5. 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.
    6. Click Next.
    7. On the Resources page, select the function you want to schedule as follows:
      1. From the Resource selection method options, select the Static - apply schedule to specific resources option.
      2. 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..
      3. In the Search and filter box, select Resource type.
      4. 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.

      5. Select the function you want to schedule.
    8. Click Next.
    9. 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.

    10. Click Next.
    11. 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:

    12. 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.

    13. Create a new dynamic group, as follows:

      1. Open the navigation menu and click Identity & Security. Under Identity, click Domains. Under Identity domain, click Dynamic groups.
      2. Follow the instructions in To create a dynamic group, and give the dynamic group a name (for example, resource-scheduler-prod-dynamic-group).
      3. 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'}
      4. Click Create Dynamic Group.
    14. Create a policy to grant the new dynamic group access to functions in OCI Functions, as follows:
      1. Open the navigation menu and click Identity & Security. Under Identity, click Policies.
      2. Follow the instructions in To create a policy, and give the policy a name (for example, resource-scheduler-prod-dyn-grp-policy).
      3. 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
      4. 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.