All Products
Search
Document Center

Function Compute:Task orchestration

Last Updated:Dec 17, 2024

You can integrate Function Compute with CloudFlow so that asynchronous invocations of functions can be applied to task processes in large-scale and complex scenarios. You can orchestrate Function Compute asynchronous tasks based on the control logic of CloudFlow, such as Sequence, Choice, and Parallel. CloudFlow coordinates the execution of tasks according to the specified steps in a reliable manner, tracks state transitions of each task, and executes the defined retry logic when necessary to ensure a smooth and successful flow task. This topic describes how to configure orchestration for asynchronous tasks.

Prerequisites

Procedure

  1. Log on to the CloudFlow console. In the top navigation bar, select a region.

  2. In the left-side navigation pane, click Workflows. On the Workflows page, click Create Workflow.

  3. In the Create Workflow dialog box, select a method to create a workflow, and then select a mode for the workflow.

    CloudFlow allows you to create workflows in standard mode or express mode. For more information about the two modes, see Standard mode and express mode. For more information, see Create a workflow based on a blank canvas.

  4. On the Edit Workflow page, define the workflow and configure a role that is used to execute the workflow.

    1. Enter the flow code.

      You can use CloudFlow Studio or YAML to edit the flow. In this example, YAML is used.

      In the upper-right corner of the flow details page, click YAML. In the left-side code editor, enter the code to be used by the flow and click Save.

      The following code snippet provides an example.

      Type: StateMachine
      Name: flow
      SpecVersion: v1
      StartAt: InvokeFunction
      States:
        - Type: Task
          Name: InvokeFunction
          Action: FC:InvokeFunction
          TaskMode: RequestComplete
          Parameters:
            invocationType: Async
            resourceArn: acs:fc:{region}:{account}:services/{serviceName}.{qualifier}/functions/{functionName}
          End: true
    2. Configure a flow role.

      In the upper-right corner of the flow details page, click Configure Workflow. In the Role Configuration section, select a role from the Execution Role drop-down list and click Save.

      Note

      Make sure that the role configured for the flow is attached the AliyunFCInvocationAccess policy.

  5. On the flow details page, click Execute in the upper-right corner to trigger the flow and check whether the flow works as expected.