Compartilhar via

在 Azure Data Factory 和 Synapse Analytics 中执行 Wait 活动

在管道中使用等待活动时,管道将等待一段指定的时间,然后继续执行后续活动。

适用于: Azure Data Factory Azure Synapse Analytics

通过用户界面创建等待活动

若要在管道中使用 Wait 活动,请完成以下步骤:

  1. 在管道“活动”窗格中搜索等待,然后将“等待”活动拖动到管道画布上。

  2. 如果尚未选择画布上的新“等待”活动,请选择该活动及其“设置”选项卡,以编辑其详细信息。

    显示“Wait”活动的 UI。

  3. 请输入活动等待的秒数。 这可以是文本数字,也可以是动态表达式、函数系统变量其他活动的输出的任意组合。

语法

{
    "name": "MyWaitActivity",
    "type": "Wait",
    "typeProperties": {
        "waitTimeInSeconds": 1
    }
}

Type 属性

属性 说明 允许的值 必需
名称 Wait 活动的名称。 字符串
类型 必须被设置为 Wait 字符串
waitTimeInSeconds 管道在继续进行处理前所等待的秒数。 整数

示例

注意事项

本部分提供运行管道的 JSON 定义和示例 PowerShell 命令。 有关使用 Azure PowerShell 和 JSON 定义创建管道的分步说明的演练,请参阅 tutorial:使用 Azure PowerShell

包含等待活动的管道

在此示例中,管道包含两个活动:UntilWait。 等待活动被配置为等待 1 秒。 管道循环运行 Web 活动,在每次运行之间等待 1 秒。

{
    "name": "DoUntilPipeline",
    "properties": {
        "activities": [
            {
                "type": "Until",
                "typeProperties": {
                    "expression": {
                        "value": "@equals('Failed', coalesce(body('MyUnauthenticatedActivity')?.status, actions('MyUnauthenticatedActivity')?.status, 'null'))",
                        "type": "Expression"
                    },
                    "timeout": "00:10:00",
                    "activities": [
                        {
                            "name": "MyUnauthenticatedActivity",
                            "type": "WebActivity",
                            "typeProperties": {
                                "method": "get",
                                "url": "https://www.fake.com/",
                                "headers": {
                                    "Content-Type": "application/json"
                                }
                            },
                            "dependsOn": [
                                {
                                    "activity": "MyWaitActivity",
                                    "dependencyConditions": [ "Succeeded" ]
                                }
                            ]
                        },
                        {
                            "type": "Wait",
                            "typeProperties": {
                                "waitTimeInSeconds": 1
                            },
                            "name": "MyWaitActivity"
                        }
                    ]
                },
                "name": "MyUntilActivity"
            }
        ]
    }
}

参阅支持的其他控制流活动: