All Products
Search
Document Center

CloudFlow:Create a workflow based on a blank canvas

Last Updated:Aug 12, 2024

A workflow in CloudFlow contains a series of task nodes. Each task is an independent operation or service unit that you want to execute. You can create a workflow in the new CloudFlow console to describe and manage your business.

Procedure

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

  2. On the Workflows page, click Create Workflow. In the Create Workflow dialog box, select Use Blank Canvas. Select Express Mode for Workflow mode. Keep the default settings for other parameters.

    image

    Note

    In the following example, the workflow is created in express mode. For information about the workflow modes supported by CloudFlow, see Standard mode and express mode.

  3. You can edit a workflow on the Edit Workflow page based on your business requirements. You can use one of the following methods to edit a workflow:

    Use CloudFlow Studio

    You can design and edit workflows in a drag-and-drop manner in the graphical interface of CloudFlow Studio.

    1. On the CloudFlow Studio tab, select a state node or flow node and drag it to the desired position on the canvas. You can also adjust the positions of nodes in an existing flow chart to modify a business flow chart.

    2. Select a state node or flow node in the flow chart and configure Basic Settings, Input Settings, Output Setting, and Troubleshooting.

    3. (Optional) On the Configure Workflow tab of the Edit Workflow page, configure the execution role of the workflow. Then, click Save and Exit.

      Note

      If your workflow involves integrating cloud services (including CloudFlow), you must configure a role that has been granted the corresponding permissions as the execution role of the workflow. For more information, see Create execution roles.

      image

      Note

      In the following example, the InvokeFunction task-type state node is configured. The following table describes the major parameters that you must configure. For other parameters, use the default values.

      Category

      Parameter

      Description

      Example

      Basic Settings

      State Name

      The name of the state node. The name describes the feature of the state.

      InvokeFunction

      Invocation Parameters

      The name, version or alias, and invocation method of the function that you want to invoke, and payloads that trigger the function.

      You can also click Switch to YAML Editing next to Invocation Parameters to specify the name, version or alias, and invocation method of the function in a YAML script.

      A sample YAML script:

      invocationType: Sync
      resourceArn: acs:fc:cn-beijing:1034354682****:functions/GPU-demo/LATEST
      body:
        key: value

      Function

      The name of the function that you want to invoke.

      myfunction

      Version or Alias

      The version or alias of the function that you want to invoke.

      LATEST

      Function Invocation Method

      The method that you want to use to invoke the function. Valid values: Sync Invocation and Async Invocation. For more information about function invocation methods, see Function invocation.

      Sync Invocation

      Request Load

      The payloads that trigger the function. You can enter payloads in the YAML or JSON format.

      {
        "key1": "value1",
        "key2.$": "$.myStateInput.key",
        "key3": 100
      }

      Next State

      Select the next state to which you want the workflow to transition. The setting takes effect in real time.

      Parallel

      Input Settings

      The filtering method of inputs. Valid values:

      • Use JSONPath to select some parameters: Enter a filter expression in the code editor. Use JSONPath to filter parameter objects as the node input.

      • Original inputs as node inputs: Use the original input of the node as the node input.

      • Use parameter filters to construct parameters: Use parameter filters to construct new parameters as the node input. You can construct parameters in the YAML or JSON format. Example:

      • FieldA: 123
        FieldB: string
        FieldC.$: $Input

      Output Settings

      The filtering method of outputs. Valid values:

      • Use JSONPath to select some parameters: Enter a filter expression in the code editor. Use JSONPath to filter parameter objects of valid output as the node output.

      • Pass raw inputs to outputs: Pass the original input of the node downstream as output.

      • Use parameter filters to construct parameters: Use parameter filters to construct new parameters as the node output. You can construct parameters in the YAML or JSON format. Example:

      • FieldA: 123
        FieldB: string
        FieldC.$: $Input

      Troubleshooting

      Retry upon Error: The retry policy when an error is caught. Click Add Retry to add retry policies.

      Error Type

      The error types that can be hit. You can select one or more error types.

      FC.BadResponse

      Maximum Retries

      The allowed maximum number of retries.

      5

      Retry Interval Seconds

      The retry interval. Maximum value: 86400. Unit: seconds.

      3

      Backoff Multiplication Factor

      The multiplier by which the retry interval increases.

      1

      Maximum Backoff Seconds

      The maximum period of time within which retries must be performed in exponential fallback mode. Unit: seconds.

      5

      Capture errors and exceptions: The capture rule that restores the workflow to an expected state when an error or exception is caught. Click Add Capture Rule to add capture rules.

      Error Type

      The error types that can be hit. You can select one or more error types.

      FC.EntitvToolLarge

      Fallback Status

      The state to which the workflow returns when a specified error is caught.

      Hello World

      Response

      The result that is returned when a specified error is caught. The result contains the error and the error is added to the input of the fallback node. You can configure a response in the YAML or JSON format.

      {
      "key":string"hello world"
      }

      Note

      You need to configure the parameters of the Troubleshooting category only in workflow integration scenarios. For more information, see Error handling.

    Use a YAML file

    You can define and manage workflows by writing concise and easy-to-read YAML configuration files.

    1. Click the YAML tab on the Edit Workflow page to switch to creating a workflow by using a YAML script. Enter a YAML script that defines the workflow in the code editor on the left. The following sample code shows a YAML configuration file. You can preview the flow chart on the right.

    2. (Optional) On the Configure Workflow tab of the Edit Workflow page, configure the execution role of the workflow. Then, click Save and Exit.

      Note

      If your workflow involves integrating cloud services (including CloudFlow), you must configure a role that has been granted the corresponding permissions as the execution role of the workflow. For more information, see Create execution roles.

      image

    3. Type: StateMachine
      Name: my-wkfl
      SpecVersion: v1
      StartAt: InvokeFunction
      States:
        - Type: Task
          Name: InvokeFunction
          Action: FC:InvokeFunction
          TaskMode: RequestComplete
          Parameters:
            invocationType: Sync
            resourceArn: >-
              acs:fc:{regionId}:{accountId}:functions/myfunction/LATEST
          Retry:
            - Errors: []
              Description: 'Retry policy #1'
              MaxAttempts: 1
              IntervalSeconds: 1
          Next: Hello World
          Catch:
            - Errors:
                - FC.AccessDenied
              Description: 'Error capture rule #1'
              Next: Hello World
        - Type: Pass
          Name: Hello World
          End: true

    Before you save the YAML configuration file, you must verify the validity of resourceArn. Replace resourceArn in resourceArn:acs:fc:{regionId}:{accountId}:functions/myfunction/LATEST by using your actual function ARN. For more information about how to obtain the ARN of a function, see Obtain the ARN of the function.

    • regionId: the ID of the region where your function resides, such as cn-beijing or cn-hangzhou.

    • accountId: the ID of your Alibaba Cloud account.

    • myfunction: the name of your function.

    • LATEST: the version of the function. You can replace LATEST with a specific version or alias based on your business requirements.

Modify a workflow

After a workflow is created, you can follow the on-screen instructions to view, modify, and delete the workflow. This section describes how to modify a workflow.

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

  2. On the Workflows page, click the workflow that you want to edit.

  3. In the upper-right corner of the workflow details page, click Edit Workflow, and then select the CloudFlow Studio or YAML mode to modify the workflow.

    • CloudFlow Studio

      You can add or remove task states. You can also configure the parameters of the Basic Settings, Input Settings, Output Settings, and Troubleshooting categories of each task state, and then click Save and Exit.

    • YAML

      Modify the workflow definition and then click Save and Exit. You can preview the flow chart in the chart section on the right of the Edit Workflow page.

    If you want to modify the description of the workflow or configure a role that executes the workflow, click Configure Workflow in the upper part of the Edit Workflow page. After you modify the description of the workflow or configure the role, click Save and Exit.

References