您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Azure 数据工厂中的管道执行和触发器Pipeline execution and triggers in Azure Data Factory

Azure 数据工厂中的“管道运行”用于定义管道执行实例。A pipeline run in Azure Data Factory defines an instance of a pipeline execution. 例如,假设你有一个管道,分别在上午 8:00、9:00 和 10:00 点执行。For example, say you have a pipeline that executes at 8:00 AM, 9:00 AM, and 10:00 AM. 在这种情况下,将分三次单独运行管道,也即有三次管道运行。In this case, there are three separate runs of the pipeline, or pipeline runs. 每次管道运行都有唯一的管道运行 ID。Each pipeline run has a unique pipeline run ID. 运行 ID 是一个 GUID,用于对该特定的管道运行进行唯一定义。A run ID is a GUID that uniquely defines that particular pipeline run.

管道运行通常通过将自变量传递给管道中定义的参数进行实例化。Pipeline runs are typically instantiated by passing arguments to parameters that you define in the pipeline. 执行管道时,可以手动,也可以使用触发器。You can execute a pipeline either manually or by using a trigger. 本文提供了有关执行管道的两种方式的详细信息。This article provides details about both ways of executing a pipeline.

手动执行(按需)Manual execution (on-demand)

管道的手动执行也称为按需执行。The manual execution of a pipeline is also referred to as on-demand execution.

例如,假设有一个需要执行的名为 copyPipeline 的基本管道。For example, say you have a basic pipeline named copyPipeline that you want to execute. 该管道有一项活动,可以将数据从 Azure Blob 存储源文件夹复制到同一存储中的目标文件夹。The pipeline has a single activity that copies from an Azure Blob storage source folder to a destination folder in the same storage. 下面的 JSON 定义显示此示例管道:The following JSON definition shows this sample pipeline:

{
    "name": "copyPipeline",
    "properties": {
        "activities": [
            {
                "type": "Copy",
                "typeProperties": {
                    "source": {
                        "type": "BlobSource"
                    },
                    "sink": {
                        "type": "BlobSink"
                    }
                },
                "name": "CopyBlobtoBlob",
                "inputs": [
                    {
                        "referenceName": "sourceBlobDataset",
                        "type": "DatasetReference"
                    }
                ],
                "outputs": [
                    {
                        "referenceName": "sinkBlobDataset",
                        "type": "DatasetReference"
                    }
                ]
            }
        ],
        "parameters": {
            "sourceBlobContainer": {
                "type": "String"
            },
            "sinkBlobContainer": {
                "type": "String"
            }
        }
    }
}

在 JSON 定义中,管道采用两个参数:sourceBlobContainersinkBlobContainerIn the JSON definition, the pipeline takes two parameters: sourceBlobContainer and sinkBlobContainer. 你在运行时将值传递给这些参数。You pass values to these parameters at runtime.

可通过以下方法之一手动运行管道:You can manually run your pipeline by using one of the following methods:

  • .NET SDK.NET SDK
  • Azure PowerShell 模块Azure PowerShell module
  • REST APIREST API
  • Python SDKPython SDK

REST APIREST API

以下示例命令演示了如何使用 REST API 手动运行管道:The following sample command shows you how to manually run your pipeline by using the REST API:

POST
https://management.azure.com/subscriptions/mySubId/resourceGroups/myResourceGroup/providers/Microsoft.DataFactory/factories/myDataFactory/pipelines/copyPipeline/createRun?api-version=2017-03-01-preview

如需完整的示例,请参阅快速入门:使用 REST API 创建数据工厂For a complete sample, see Quickstart: Create a data factory by using the REST API.

Azure PowerShellAzure PowerShell

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

以下示例命令演示了如何使用 Azure PowerShell 手动运行管道:The following sample command shows you how to manually run your pipeline by using Azure PowerShell:

Invoke-AzDataFactoryV2Pipeline -DataFactory $df -PipelineName "Adfv2QuickStartPipeline" -ParameterFile .\PipelineParameters.json

请在请求有效负载的正文中传递参数。You pass parameters in the body of the request payload. 在 .NET SDK、Azure PowerShell 和 Python SDK 中,请在作为参数传递给调用的字典中传递值:In the .NET SDK, Azure PowerShell, and the Python SDK, you pass values in a dictionary that's passed as an argument to the call:

{
  "sourceBlobContainer": "MySourceFolder",
  "sinkBlobContainer": "MySinkFolder"
}

响应有效负载是管道运行的唯一 ID:The response payload is a unique ID of the pipeline run:

{
  "runId": "0448d45a-a0bd-23f3-90a5-bfeea9264aed"
}

如需完整的示例,请参阅快速入门:使用 Azure PowerShell 创建数据工厂For a complete sample, see Quickstart: Create a data factory by using Azure PowerShell.

.NET SDK.NET SDK

以下示例调用演示了如何使用 .NET SDK 手动运行管道:The following sample call shows you how to manually run your pipeline by using the .NET SDK:

client.Pipelines.CreateRunWithHttpMessagesAsync(resourceGroup, dataFactoryName, pipelineName, parameters)

如需完整的示例,请参阅快速入门:使用 .NET SDK 创建数据工厂For a complete sample, see Quickstart: Create a data factory by using the .NET SDK.

备注

可以使用 .NET SDK 从 Azure Functions、自己的 Web 服务等位置调用数据工厂管道。You can use the .NET SDK to invoke Data Factory pipelines from Azure Functions, from your own web services, and so on.

触发器执行Trigger execution

触发器是可以执行管道运行的另一种方法。Triggers are another way that you can execute a pipeline run. 触发器表示一个处理单元,用于确定何时需要启动管道执行。Triggers represent a unit of processing that determines when a pipeline execution needs to be kicked off. 目前,数据工厂支持三种类型的触发器:Currently, Data Factory supports three types of triggers:
  • 计划触发器:按时钟计划调用管道的触发器。Schedule trigger: A trigger that invokes a pipeline on a wall-clock schedule.

  • 翻转窗口触发器:一种触发器,可以定期运行,同时还能保留状态。Tumbling window trigger: A trigger that operates on a periodic interval, while also retaining state.

  • 基于事件的触发器:响应某个事件的触发器。Event-based trigger: A trigger that responds to an event.

管道和触发器具有多对多关系(翻转窗口触发器除外)。多个触发器可以启动单个管道,或单个触发器可以启动多个管道。Pipelines and triggers have a many-to-many relationship (except for the tumbling window trigger).Multiple triggers can kick off a single pipeline, or a single trigger can kick off multiple pipelines. 在以下触发器定义中,pipelines 属性是指一系列由特定的触发器触发的管道。In the following trigger definition, the pipelines property refers to a list of pipelines that are triggered by the particular trigger. 属性定义包括管道参数的值。The property definition includes values for the pipeline parameters.

基本的触发器定义Basic trigger definition

{
    "properties": {
        "name": "MyTrigger",
        "type": "<type of trigger>",
        "typeProperties": {...},
        "pipelines": [
            {
                "pipelineReference": {
                    "type": "PipelineReference",
                    "referenceName": "<Name of your pipeline>"
                },
                "parameters": {
                    "<parameter 1 Name>": {
                        "type": "Expression",
                        "value": "<parameter 1 Value>"
                    },
                    "<parameter 2 Name>": "<parameter 2 Value>"
                }
            }
        ]
    }
}

计划触发器Schedule trigger

计划触发器按时钟计划运行管道。A schedule trigger runs pipelines on a wall-clock schedule. 此触发器支持定期和高级日历选项。This trigger supports periodic and advanced calendar options. 例如,此触发器支持“每周”或“星期一下午 5:00 和星期四晚上 9:00”之类的时间间隔。For example, the trigger supports intervals like "weekly" or "Monday at 5:00 PM and Thursday at 9:00 PM." 计划触发器很灵活,因为数据集模式与数据类型无关,该触发器不区分时序数据和非时序数据。The schedule trigger is flexible because the dataset pattern is agnostic, and the trigger doesn't discern between time-series and non-time-series data.

如需计划触发器的详细信息和示例,请参阅创建计划触发器For more information about schedule triggers and for examples, see Create a schedule trigger.

计划触发器定义Schedule trigger definition

创建计划触发器时,请使用 JSON 定义指定计划和定期触发。When you create a schedule trigger, you specify scheduling and recurrence by using a JSON definition.

若要使用计划触发器启动管道运行,请在触发器定义中包括特定管道的管道引用。To have your schedule trigger kick off a pipeline run, include a pipeline reference of the particular pipeline in the trigger definition. 管道和触发器具有“多对多”关系。Pipelines and triggers have a many-to-many relationship. 多个触发器可以启动单个管道。Multiple triggers can kick off a single pipeline. 单个触发器可以启动多个管道。A single trigger can kick off multiple pipelines.

{
  "properties": {
    "type": "ScheduleTrigger",
    "typeProperties": {
      "recurrence": {
        "frequency": <<Minute, Hour, Day, Week, Year>>,
        "interval": <<int>>, // How often to fire
        "startTime": <<datetime>>,
        "endTime": <<datetime>>,
        "timeZone": "UTC",
        "schedule": { // Optional (advanced scheduling specifics)
          "hours": [<<0-24>>],
          "weekDays": [<<Monday-Sunday>>],
          "minutes": [<<0-60>>],
          "monthDays": [<<1-31>>],
          "monthlyOccurrences": [
            {
              "day": <<Monday-Sunday>>,
              "occurrence": <<1-5>>
            }
          ]
        }
      }
    },
  "pipelines": [
    {
      "pipelineReference": {
        "type": "PipelineReference",
        "referenceName": "<Name of your pipeline>"
      },
      "parameters": {
        "<parameter 1 Name>": {
          "type": "Expression",
          "value": "<parameter 1 Value>"
        },
        "<parameter 2 Name>": "<parameter 2 Value>"
      }
    }
  ]}
}

重要

parameters 属性是 pipelines 元素的必需属性。The parameters property is a mandatory property of the pipelines element. 如果管道不使用任何参数,则必须包括一个空的针对 parameters 属性的 JSON 定义。If your pipeline doesn't take any parameters, you must include an empty JSON definition for the parameters property.

架构概述Schema overview

下表概述了与触发器的定期触发和计划相关的主要架构元素:The following table provides a high-level overview of the major schema elements that are related to recurrence and scheduling a trigger:

JSON 属性JSON property 说明Description
startTimestartTime 一个日期时间值。A date-time value. 对于基本的计划,startTime 属性的值适用于第一个匹配项。For basic schedules, the value of the startTime property applies to the first occurrence. 对于复杂的计划,触发器的启动时间不早于指定的 startTime 值。For complex schedules, the trigger starts no sooner than the specified startTime value.
endTimeendTime 触发器的结束日期和时间。The end date and time for the trigger. 该触发器不在指定的结束日期和时间之后执行。The trigger doesn't execute after the specified end date and time. 属性的值不能是过去的时间。The value for the property can't be in the past.
timeZonetimeZone 时区。The time zone. 目前仅支持 UTC 时区。Currently, only the UTC time zone is supported.
recurrencerecurrence 一个 recurrence 对象,指定触发器的定期触发规则。A recurrence object that specifies the recurrence rules for the trigger. recurrence 对象支持 frequencyintervalendTimecountschedule 元素。The recurrence object supports the frequency, interval, endTime, count, and schedule elements. 定义 recurrence 对象时,frequency 元素是必需的。When a recurrence object is defined, the frequency element is required. recurrence 对象的其他元素为可选元素。The other elements of the recurrence object are optional.
频率frequency 触发器定期触发的频率单位。The unit of frequency at which the trigger recurs. 支持的值包括 "minute"、"hour"、"day"、"week" 和 "month"。The supported values include "minute", "hour", "day", "week", and "month".
intervalinterval 一个正整数,表示 frequency 值对应的时间间隔。A positive integer that denotes the interval for the frequency value. frequency 值决定了触发器的运行频率。The frequency value determines how often the trigger runs. 例如,如果 interval 为 3,frequency 为 "week",则触发器每三周定期触发一次。For example, if the interval is 3 and the frequency is "week", the trigger recurs every three weeks.
scheduleschedule 触发器的定期触发计划。The recurrence schedule for the trigger. 指定了 frequency 值的触发器会根据定期触发计划更改其定期触发。A trigger with a specified frequency value alters its recurrence based on a recurrence schedule. schedule 属性包含对定期触发的修改,这些修改是按分钟、小时、工作日、月份日期和周次进行的。The schedule property contains modifications for the recurrence that are based on minutes, hours, week days, month days, and week number.

计划触发器示例Schedule trigger example

{
    "properties": {
        "name": "MyTrigger",
        "type": "ScheduleTrigger",
        "typeProperties": {
            "recurrence": {
                "frequency": "Hour",
                "interval": 1,
                "startTime": "2017-11-01T09:00:00-08:00",
                "endTime": "2017-11-02T22:00:00-08:00"
            }
        },
        "pipelines": [{
                "pipelineReference": {
                    "type": "PipelineReference",
                    "referenceName": "SQLServerToBlobPipeline"
                },
                "parameters": {}
            },
            {
                "pipelineReference": {
                    "type": "PipelineReference",
                    "referenceName": "SQLServerToAzureSQLPipeline"
                },
                "parameters": {}
            }
        ]
    }
}

架构默认值、限制和示例Schema defaults, limits, and examples

JSON 属性JSON property 类型Type 必选Required 默认值Default value 有效值Valid values 示例Example
startTimestartTime 字符串string Yes None ISO 8601 日期时间ISO 8601 date-times "startTime" : "2013-01-09T09:30:00-08:00"
recurrencerecurrence 对象object Yes None recurrence 对象A recurrence object "recurrence" : { "frequency" : "monthly", "interval" : 1 }
intervalinterval 数字number No 11 1 到 10001 to 1000 "interval":10
endTimeendTime 字符串string Yes None 代表将来某个时间的日期/时间值A date-time value that represents a time in the future "endTime" : "2013-02-09T09:30:00-08:00"
scheduleschedule 对象object No None schedule 对象A schedule object "schedule" : { "minute" : [30], "hour" : [8,17] }

startTime 属性startTime property

下表说明了 startTime 属性如何控制触发器运行:The following table shows you how the startTime property controls a trigger run:

startTime 值startTime value 不按计划循环Recurrence without schedule 按计划循环Recurrence with schedule
开始时间在过去Start time is in the past 计算开始时间后的第一个将来执行时间,并在该时间运行。Calculates the first future execution time after the start time, and runs at that time.

根据上次执行时间进行计算后,运行后续执行。Runs subsequent executions calculated from the last execution time.

请参阅此表后面的示例。See the example that follows this table.
触发器不会早于指定的开始时间启动。The trigger starts no sooner than the specified start time. 第一次循环基于从开始时间计算的计划。The first occurrence is based on the schedule, calculated from the start time.

后续执行的运行取决于定期触发计划。Runs subsequent executions based on the recurrence schedule.
开始时间在将来或当前Start time is in the future or the current time 在指定的开始时间运行一次。Runs once at the specified start time.

根据上次执行时间进行计算后,运行后续执行。Runs subsequent executions calculated from the last execution time.
触发器不会早于指定的开始时间启动。The trigger starts no sooner than the specified start time. 第一次循环基于从开始时间计算的计划。The first occurrence is based on the schedule, calculated from the start time.

后续执行的运行取决于定期触发计划。Runs subsequent executions based on the recurrence schedule.

让我们查看一个示例,了解在开始时间是过去的时间,并且指定了定期触发但未指定计划的情况下,会发生什么事情。Let's look at an example of what happens when the start time is in the past, with a recurrence, but no schedule. 假设当前时间为 2017-04-08 13:00,开始时间为 2017-04-07 14:00,定期触发为每两天触发一次。Assume that the current time is 2017-04-08 13:00, the start time is 2017-04-07 14:00, and the recurrence is every two days. (通过将frequency属性设置为 "day" 并将interval属性设置为2来定义重复值。)请注意, startTime值为过去,并发生在当前时间之前。(The recurrence value is defined by setting the frequency property to "day" and the interval property to 2.) Notice that the startTime value is in the past and occurs before the current time.

在上述情况下,首次执行时间为 2017-04-09 14:00。Under these conditions, the first execution is 2017-04-09 at 14:00. 计划程序引擎从开始时间计算执行循环。The Scheduler engine calculates execution occurrences from the start time. 过去的所有实例会被丢弃。Any instances in the past are discarded. 引擎将使用将来发生的下一个实例。The engine uses the next instance that occurs in the future. 在这种情况下,开始时间为 2017-04-07 的下午 2:00。In this scenario, the start time is 2017-04-07 at 2:00 PM. 下一个实例为从该时间算起的 2 天,即 2017-04-09 的下午 2:00。The next instance is two days from that time, which is on 2017-04-09 at 2:00 PM.

首次执行时间是相同的,不管 startTime 是 2017-04-05 14:00 还是 2017-04-01 14:00。The first execution time is the same even whether startTime is 2017-04-05 14:00 or 2017-04-01 14:00. 在首次执行后,使用该计划计算后续执行。After the first execution, subsequent executions are calculated by using the schedule. 因此,后续的执行时间是 2017-04-11 下午 2:00,然后是 2017-04-13 下午 2:00,再然后是 2017-04-15 下午 2:00,依此类推。Therefore, the subsequent executions are on 2017-04-11 at 2:00 PM, then on 2017-04-13 at 2:00 PM, then on 2017-04-15 at 2:00 PM, and so on.

最后,如果没有在触发器的计划中设置小时或分钟,则会将第一次执行时对应的小时或分钟值用作默认值。Finally, when hours or minutes aren’t set in the schedule for a trigger, the hours or minutes of the first execution are used as defaults.

schedule 属性schedule property

可以使用 schedule 来限制触发器执行的次数。You can use schedule to limit the number of trigger executions. 例如,如果触发器的频率为按月,根据计划仅在第 31 天运行,则该触发器仅在有 31 日的月份运行。For example, if a trigger with a monthly frequency is scheduled to run only on day 31, the trigger runs only in those months that have a thirty-first day.

还可以使用 schedule 来扩展触发器执行的次数。You can also use schedule to expand the number of trigger executions. 例如,如果触发器的频率为按月,根据计划在每月的第 1 天和第 2 天运行,则该触发器会在当月的第 1 天和第 2 天运行,而不是每月运行一次。For example, a trigger with a monthly frequency that's scheduled to run on month days 1 and 2, runs on the first and second days of the month, rather than once a month.

如果指定了多个 schedule 元素,则求值顺序为从大到小的计划设置:周次、月份日期、星期、小时、分钟。If multiple schedule elements are specified, the order of evaluation is from the largest to the smallest schedule setting: week number, month day, week day, hour, minute.

下表详细描述了 schedule 元素:The following table describes the schedule elements in detail:

JSON 元素JSON element 说明Description 有效值Valid values
分钟数minutes 运行触发器的小时中的分钟。Minutes of the hour at which the trigger runs. - 整数- Integer
- 整数数组- Array of integers
小时数hours 运行触发器的日期中的小时。Hours of the day at which the trigger runs. - 整数- Integer
- 整数数组- Array of integers
工作日weekDays 运行触发器的星期日期。Days of the week the trigger runs. 此值只能使用与星期相关的频率来指定。The value can be specified only with a weekly frequency.
- Monday- Monday
- Tuesday- Tuesday
- Wednesday- Wednesday
- Thursday- Thursday
- Friday- Friday
- Saturday- Saturday
- Sunday- Sunday
- 星期值的数组(最大数组值为 7)- Array of day values (maximum array size is 7)

星期值不区分大小写Day values are not case-sensitive
monthlyOccurrencesmonthlyOccurrences 运行触发器的月份日期。Days of the month on which the trigger runs. 此值只能使用与月份相关的频率来指定。The value can be specified with a monthly frequency only. - monthlyOccurrence 对象的数组:{ "day": day, "occurrence": occurrence }- Array of monthlyOccurrence objects: { "day": day, "occurrence": occurrence }
- day 属性表示运行触发器那天为星期几。- The day attribute is the day of the week on which the trigger runs. 例如,如果 monthlyOccurrences 属性的 day 值为 {Sunday},则表示在当月的每个星期日运行触发器。For example, a monthlyOccurrences property with a day value of {Sunday} means every Sunday of the month. day 属性是必需的。The day attribute is required.
- occurrence 属性是指定的 day 在当月的匹配项。- The occurrence attribute is the occurrence of the specified day during the month. 例如,如果 monthlyOccurrences 属性的 dayoccurrence 值为 {Sunday, -1},则表示在当月的最后一个星期日运行触发器。For example, a monthlyOccurrences property with day and occurrence values of {Sunday, -1} means the last Sunday of the month. occurrence 属性是可选的。The occurrence attribute is optional.
monthDaysmonthDays 运行触发器的月份日期。Day of the month on which the trigger runs. 此值只能使用与月份相关的频率来指定。The value can be specified with a monthly frequency only. <= -1 且 >= -31 的任意值- Any value <= -1 and >= -31
>= 1 且 <= 31 的任意值- Any value >= 1 and <= 31
- 值组成的数组- Array of values

翻转窗口触发器Tumbling window trigger

翻转窗口触发器是一类可以在保留状态的同时按周期性的时间间隔(从指定的开始时间算起)触发的触发器。Tumbling window triggers are a type of trigger that fires at a periodic time interval from a specified start time, while retaining state. 翻转窗口是一系列固定大小、非重叠且连续的时间间隔。Tumbling windows are a series of fixed-sized, non-overlapping, and contiguous time intervals.

如需翻转窗口触发器的详细信息和示例,请参阅创建翻转窗口触发器For more information about tumbling window triggers and for examples, see Create a tumbling window trigger.

基于事件的触发器Event-based trigger

基于事件的触发器在 Azure Blob 存储中通过运行管道来响应某个事件,例如某个文件已到达,或者某个文件已删除。An event-based trigger runs pipelines in response to an event, such as the arrival of a file, or the deletion of a file, in Azure Blob Storage.

若要详细了解基于事件的触发器,请参阅创建可以通过运行管道来响应事件的触发器For more information about event-based triggers, see Create a trigger that runs a pipeline in response to an event.

触发器定期触发计划示例Examples of trigger recurrence schedules

此部分提供定期触发计划的示例,This section provides examples of recurrence schedules. 重点介绍 schedule 对象及其元素。It focuses on the schedule object and its elements.

这些示例假定 interval 值为 1,且根据计划定义,frequency 值是正确的。The examples assume that the interval value is 1, and that the frequency value is correct according to the schedule definition. 例如,不能在 frequency 值为 "day" 的同时,在 schedule 对象中有一个 monthDays 修改项。For example, you can't have a frequency value of "day" and also have a monthDays modification in the schedule object. 这些类型的限制在上一部分的表中已说明过。These kinds of restrictions are described in the table in the preceding section.

示例Example 说明Description
{"hours":[5]} 在每天早晨 5:00 运行。Run at 5:00 AM every day.
{"minutes":[15], "hours":[5]} 在每天早晨 5:15 运行。Run at 5:15 AM every day.
{"minutes":[15], "hours":[5,17]} 在每天早晨 5:15 和下午 5:15 运行。Run at 5:15 AM and 5:15 PM every day.
{"minutes":[15,45], "hours":[5,17]} 在每天早晨 5:15、5:45 和下午 5:15、5:45 运行。Run at 5:15 AM, 5:45 AM, 5:15 PM, and 5:45 PM every day.
{"minutes":[0,15,30,45]} 每 15 分钟运行一次。Run every 15 minutes.
{hours":[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]} 每小时运行一次。Run every hour.

此触发器每小时运行一次。This trigger runs every hour. 如果指定了值,则分钟由 startTime 值控制。The minutes are controlled by the startTime value, when a value is specified. 如果未指定值,则分钟由创建时间控制。If a value isn't specified, the minutes are controlled by the creation time. 例如,如果开始时间或创建时间(以适用的为准)为中午 12:25,则触发器会在 00:25、01:25、02:25 ... 23:25 运行。For example, if the start time or creation time (whichever applies) is 12:25 PM, the trigger runs at 00:25, 01:25, 02:25, ..., and 23:25.

该计划相当于为触发器指定了 frequency 值 "hour"、interval 值 1,无 scheduleThis schedule is equivalent to having a trigger with a frequency value of "hour", an interval value of 1, and no schedule. 可以使用 frequencyinterval 值不同于此的该计划来创建其他触发器。This schedule can be used with different frequency and interval values to create other triggers. 例如,如果 frequency 值为 "month",则此计划每月仅运行一次,而不是每天运行一次(如果 frequency 值为 "day")。For example, when the frequency value is "month", the schedule runs only once a month, rather than every day when the frequency value is "day".
{"minutes":[0]} 每小时整点运行。Run every hour on the hour.

此触发器每小时整点运行,开始时间为晚上 12:00、凌晨 1:00、凌晨 2:00,依此类推。This trigger runs every hour on the hour starting at 12:00 AM, 1:00 AM, 2:00 AM, and so on.

此计划相当于 frequency 值为 "hour",startTime 值为零分钟,没有 schedulefrequency 值为 "day" 的触发器。This schedule is equivalent to a trigger with a frequency value of "hour" and a startTime value of zero minutes, and no schedule but a frequency value of "day". 如果 frequency 值为 "week" 或 "month",则此计划会相应地在每周的某一天或每月的某一天执行。If the frequency value is "week" or "month", the schedule executes one day a week or one day a month only, respectively.
{"minutes":[15]} 在整点的 15 分钟过后运行。Run at 15 minutes past every hour.

此触发器每小时在整点过后 15 分钟运行,开始时间为凌晨 00:15、凌晨 1:15、凌晨 2:15,依此类推,结束时间为晚上 11:15。This trigger runs every hour at 15 minutes past the hour starting at 00:15 AM, 1:15 AM, 2:15 AM, and so on, and ending at 11:15 PM.
{"hours":[17], "weekDays":["saturday"]} 在每周星期六的下午 5:00 运行。Run at 5:00 PM on Saturdays every week.
{"hours":[17], "weekDays":["monday", "wednesday", "friday"]} 在每周星期一、星期三和星期五的下午 5:00 运行。Run at 5:00 PM on Monday, Wednesday, and Friday every week.
{"minutes":[15,45], "hours":[17], "weekDays":["monday", "wednesday", "friday"]} 在每周星期一、星期三和星期五的下午 5:15 和下午 5:45 运行。Run at 5:15 PM and 5:45 PM on Monday, Wednesday, and Friday every week.
{"minutes":[0,15,30,45], "weekDays":["monday", "tuesday", "wednesday", "thursday", "friday"]} 在工作日每 15 分钟运行一次。Run every 15 minutes on weekdays.
{"minutes":[0,15,30,45], "hours": [9, 10, 11, 12, 13, 14, 15, 16] "weekDays":["monday", "tuesday", "wednesday", "thursday", "friday"]} 在工作日的早晨 9:00 到下午 4:45 之间每 15 分钟运行一次。Run every 15 minutes on weekdays between 9:00 AM and 4:45 PM.
{"weekDays":["tuesday", "thursday"]} 在星期二和星期四的指定开始时间运行。Run on Tuesdays and Thursdays at the specified start time.
{"minutes":[0], "hours":[6], "monthDays":[28]} 在每月 28 日的早晨 6:00 运行(假设 frequency 值为 "month")。Run at 6:00 AM on the twenty-eighth day of every month (assuming a frequency value of "month").
{"minutes":[0], "hours":[6], "monthDays":[-1]} 在当月最后一天的早晨 6:00 运行。Run at 6:00 AM on the last day of the month.

若要在某个月的最后一天运行触发器,请使用 -1 而不是 28 日、29 日、30 日或 31 日。To run a trigger on the last day of a month, use -1 instead of day 28, 29, 30, or 31.
{"minutes":[0], "hours":[6], "monthDays":[1,-1]} 在每月第一天和最后一天的早晨 6:00 运行。Run at 6:00 AM on the first and last day of every month.
{monthDays":[1,14]} 在每月第一天和第 14 天的指定开始时间运行。Run on the first and fourteenth day of every month at the specified start time.
{"minutes":[0], "hours":[5], "monthlyOccurrences":[{"day":"friday", "occurrence":1}]} 在每月第一个星期五的早晨 5:00 运行。Run on the first Friday of every month at 5:00 AM.
{"monthlyOccurrences":[{"day":"friday", "occurrence":1}]} 在每月第一个星期五的指定开始时间运行。Run on the first Friday of every month at the specified start time.
{"monthlyOccurrences":[{"day":"friday", "occurrence":-3}]} 在每月从月末算起的第三个星期五的指定开始时间运行。Run on the third Friday from the end of the month, every month, at the specified start time.
{"minutes":[15], "hours":[5], "monthlyOccurrences":[{"day":"friday", "occurrence":1},{"day":"friday", "occurrence":-1}]} 在每月第一个和最后一个星期五的早晨 5:15 运行。Run on the first and last Friday of every month at 5:15 AM.
{"monthlyOccurrences":[{"day":"friday", "occurrence":1},{"day":"friday", "occurrence":-1}]} 在每月第一个和最后一个星期五的指定开始时间运行。Run on the first and last Friday of every month at the specified start time.
{"monthlyOccurrences":[{"day":"friday", "occurrence":5}]} 在每月第五个星期五的指定开始时间运行。Run on the fifth Friday of every month at the specified start time.

当月份中没有第五个星期五时,不运行管道。When there's no fifth Friday in a month, the pipeline doesn't run. 若要在月份的最后一个星期五运行触发器,可以考虑使用 -1 而不是 5 作为 occurrence 值。To run the trigger on the last occurring Friday of the month, consider using -1 instead of 5 for the occurrence value.
{"minutes":[0,15,30,45], "monthlyOccurrences":[{"day":"friday", "occurrence":-1}]} 在月份的最后一个星期五每 15 分钟运行一次。Run every 15 minutes on the last Friday of the month.
{"minutes":[15,45], "hours":[5,17], "monthlyOccurrences":[{"day":"wednesday", "occurrence":3}]} 在每月第三个星期三的早晨 5:15、早晨 5:45、下午 5:15、下午 5:45 运行。Run at 5:15 AM, 5:45 AM, 5:15 PM, and 5:45 PM on the third Wednesday of every month.

触发器类型比较Trigger type comparison

翻转窗口触发器和计划触发器都按时间检测信号运行,The tumbling window trigger and the schedule trigger both operate on time heartbeats. 那么其不同之处在哪里?How are they different?

下表对翻转窗口触发器和计划触发器进行了比较:The following table provides a comparison of the tumbling window trigger and schedule trigger:

翻转窗口触发器Tumbling window trigger 计划触发器Schedule trigger
回填方案Backfill scenarios Supported. 可以针对过去的窗口来计划管道运行。Pipeline runs can be scheduled for windows in the past. 不支持。Not supported. 只能在从现在的时间到未来的时间这个时段内执行管道运行。Pipeline runs can be executed only on time periods from the current time and the future.
可靠性Reliability 100% 的可靠性。100% reliability. 可以针对所有窗口(从指定的开始日期算起,没有间隔)来计划管道运行。Pipeline runs can be scheduled for all windows from a specified start date without gaps. 可靠性较低。Less reliable.
重试功能Retry capability Supported. 失败的管道运行的重试策略默认设置为 0,也可由用户在触发器定义中指定。Failed pipeline runs have a default retry policy of 0, or a policy that's specified by the user in the trigger definition. 在管道运行因并发/服务器/数量限制(即状态代码 400:用户错误;429:请求过多;500:内部服务器错误)而失败时自动重试。Automatically retries when pipeline runs fail due to concurrency/server/throttling limits (that is, status codes 400: User Error, 429: Too many requests, and 500: Internal Server error). 不支持。Not supported.
并发Concurrency Supported. 用户可以为触发器显式设置并发限制。Users can explicitly set concurrency limits for the trigger. 允许 1 到 50 个并发的触发管道运行。Allows between 1 and 50 concurrent triggered pipeline runs. 不支持。Not supported.
系统变量System variables 支持使用 WindowStartWindowEnd 系统变量。Supports the use of the WindowStart and WindowEnd system variables. 用户可以访问在触发器定义中充当触发器系统变量的 triggerOutputs().windowStartTimetriggerOutputs().windowEndTimeUsers can access triggerOutputs().windowStartTime and triggerOutputs().windowEndTime as trigger system variables in the trigger definition. 这两个值分别用作窗口开始时间和窗口结束时间。The values are used as the window start time and window end time, respectively. 例如,如果翻转窗口触发器每小时运行一次,则对于凌晨 1:00 到凌晨 2:00 这个窗口,相应的定义为 triggerOutputs().WindowStartTime = 2017-09-01T01:00:00ZtriggerOutputs().WindowEndTime = 2017-09-01T02:00:00ZFor example, for a tumbling window trigger that runs every hour, for the window 1:00 AM to 2:00 AM, the definition is triggerOutputs().WindowStartTime = 2017-09-01T01:00:00Z and triggerOutputs().WindowEndTime = 2017-09-01T02:00:00Z. 不支持。Not supported.
管道-触发器关系Pipeline-to-trigger relationship 支持一对一关系。Supports a one-to-one relationship. 只能触发一个管道。Only one pipeline can be triggered. 支持多对多关系。Supports many-to-many relationships. 多个触发器可以启动单个管道。Multiple triggers can kick off a single pipeline. 单个触发器可以启动多个管道。A single trigger can kick off multiple pipelines.

后续步骤Next steps

参阅以下教程:See the following tutorials: