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
An asynchronous task is created. For more information, see Manage tasks.
Function Compute is granted the permissions to access CloudFlow. For more information, see Grant Function Compute permissions to access other Alibaba Cloud services.
Procedure
Log on to the CloudFlow console. In the top navigation bar, select a region.
In the left-side navigation pane, click Workflows. On the Workflows page, click Create Workflow.
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.
On the Edit Workflow page, define the workflow and configure a role that is used to execute the workflow.
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
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.
NoteMake sure that the role configured for the flow is attached the AliyunFCInvocationAccess policy.
On the flow details page, click Execute in the upper-right corner to trigger the flow and check whether the flow works as expected.