Create a time-based schedule

更新时间:
复制 MD 格式

Use the time-based schedule feature of Serverless Workflow to periodically run a workflow that invokes a Function Compute (FC) function.

How it works

A time-based schedule triggers a workflow as follows:

  1. In Serverless Workflow, you define a task step that invokes a function in Function Compute (FC).

  2. In Serverless Workflow, you create a time-based schedule. The schedule then automatically runs the workflow, which executes the function defined in the task step.

8b0732b23943d746

Procedure

  1. Log on to the Serverless Workflow console.

  2. In the top navigation bar, select a region.

  3. In the left-side navigation pane, click Application Center.

  4. On the Application Center page, click Create Application.

  5. On the Create Application page, on the Select Template tab, select the Timer template and click Configure and Deploy.

  6. On the Configure and Deploy tab, configure the parameters and click Deploy.

    The following table describes the parameters.

    Parameter

    Description

    Application Name

    The name of your application. The name must be unique within your Alibaba Cloud account.

    Note

    Your application is a custom Resource Orchestration Service (ROS) resource. View the resource in the Resource Orchestration Service (ROS) console.

    Cron

    The cron expression that defines the workflow's schedule. For more information, see Schedule time parameters.

    Input

    The input for the scheduled workflow. The input must be in JSON format. By default, this field is empty. For more information, see Input format.

    After a successful deployment, you can view the application's outputs and resource list on the Overview tab of the application in Application Center. The outputs include applicationName (value: timer) and entrypointFlowName. The resource list shows the six created cloud resources: ALIYUN::FC::Service, ALIYUN::FNF::Schedule, ALIYUN::FC::Function, ALIYUN::FNF::Flow, ALIYUN::RAM::Role, and ALIYUN::RAM::AttachPolicyToRole. All resources have a status of Create Succeeded.

    • RAM roles: 'AliyunFCInvocationAccessflowRole' for function invocation and 'flowRole' for the workflow.

    • Function Compute resources: a service named 'service' and a function named 'servicehello'.

    • Serverless Workflow resources: a flow named 'flow' and a time-based schedule (ALIYUN::FNF::Schedule).

  7. When the creation is complete, click OK to start the flow execution.

  8. You are redirected to the Flows page. In the dialog box that appears, specify an Execution Name (optional) and the Input (optional), and then click Start Execution.

    • Execution Name: The name for the execution. It must be 1 to 128 characters long and can contain letters, digits, underscores (_), and hyphens (-). It cannot start with a hyphen (-).

    • Input (optional): The value must be in JSON format.

    The following sample is a flow definition that uses a task step to invoke the hello function of Function Compute.

    version: v1
    type: flow
    steps:
      # task step to invoke FC function hello
      - type: task
        name: hello
        resourceArn: acs:fc:::services/service-CD946B9A9F36/functions/hello                   

    You can modify the flow definition to implement your business logic. For more information, see Modify a flow.