共用方式為


在 Azure Data Factory 和 Synapse Analytics 中執行 Wait 活動

在管線中使用 Wait (等待) 活動時,管線便會等待一段指定的時間,然後再繼續執行後續的活動。

適用於:Azure Data Factory Azure Synapse Analytics

提示

試用 Microsoft Fabric 中的 Data Factory,這是適用於企業的全方位分析解決方案。 Microsoft Fabric 涵蓋從資料移動到資料科學、即時分析、商業智慧和報告的所有項目。 了解如何免費開始新的試用

使用 UI 建立 Wait 活動

若要在管線中使用 Wait 活動,請完成下列步驟:

  1. 在「管線活動」窗格中搜尋 Wait,然後將 Wait 活動拖曳至管線畫布。

  2. 在畫布上選取新的 Wait 活動 (如未選取) 和其設定索引標籤以編輯詳細資料。

    Shows the UI for a Wait activity.

  3. 輸入要等候活動的秒數。 可以是常值數字,或是任何動態運算式、函式系統變數其他活動的輸出的組合。

語法

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

類型屬性

屬性 說明 允許的值 必要
NAME Wait 活動的名稱。 String Yes
type 必須設為 Wait String Yes
waitTimeInSeconds 管線繼續進行處理之前所等待的秒數。 整數 Yes

範例

注意

本節提供 JSON 定義和 PowerShell 命令範例,以供執行管線。 針對使用 Azure PowerShell 和 JSON 定義來建立管線,如需包含逐步指示的逐步解說,請參閱教學課程:使用 Azure PowerShell 來建立資料處理站

具有 Wait 活動的管線

在此範例中,管線有兩個活動:UntilWait。 Wait (等待) 活動設定為等待一秒鐘。 管線是在迴圈中執行 Wait (等待) 活動,每次執行之間會等待一秒鐘。

{
    "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"
            }
        ]
    }
}

查看其他支援的控制流程活動: