使用 Azure 计划程序创建和计划第一个作业 - Azure 门户Create and schedule your first job with Azure Scheduler - Azure portal

Important

Azure 逻辑应用将替换即将停用的 Azure 计划程序。Azure Logic Apps is replacing Azure Scheduler, which is being retired. 若要继续使用在计划程序中设置的作业,请尽快迁移到 Azure 逻辑应用To continue working with the jobs that you set up in Scheduler, please migrate to Azure Logic Apps as soon as possible.

本教程演示了如何轻松创建和计划作业,然后监视并管理该作业。This tutorial shows how easily you can create and schedule a job, and then monitor and manage that job.

如果没有 Azure 订阅,请注册一个免费 Azure 帐户If you don't have an Azure subscription, sign up for a free Azure account.

创建作业Create job

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 在 Azure 主菜单上选择“创建资源” 。On the main Azure menu, select Create a resource. 在搜索框中输入“计划程序”。In the search box, enter "scheduler". 在结果列表中,选择“计划程序”,然后选择“创建” 。From the results list, select Scheduler, and then choose Create.

    创建计划程序资源

    现在,创建一个将 GET 请求发送到此 URL 的作业:https://www.microsoft.com/Now create a job that sends a GET request to this URL: https://www.microsoft.com/

  3. 在“计划程序作业”下,输入这些信息: Under Scheduler Job, enter this information:

    属性Property 示例值Example value 说明Description
    名称Name getMicrosoftgetMicrosoft 作业的名称The name for your job
    作业集合Job collection <job-collection-name> 创建一个作业集合,或选择现有的集合。Create a job collection, or select an existing collection.
    订阅Subscription <Azure-subscription-name><Azure-subscription-name> Azure 订阅的名称The name for your Azure subscription
  4. 选择“操作设置 - 配置”,提供此信息,完成后选择“确定”:Select Action settings - Configure, provide this information, and then choose OK when you're done:

    属性Property 示例值Example value 说明Description
    操作Action HttpHttp 要运行的操作类型The type of action to run
    方法Method GetGet 要调用的方法The method to call
    URLURL https://www.microsoft.com 目标 URLThe destination URL

    定义作业

  5. 选择“日程安排 - 配置”,定义计划,完成后选择“确定”:Select Schedule - Configure, define the schedule, and then select OK when you're done:

    尽管可以创建一次性作业,但此示例设置的是定期计划。Although you can create a one-time job, this example sets up a recurrence schedule.

    属性Property 示例值Example value 说明Description
    定期Recurrence 定期 Recurring 一次性或定期作业Either a one-time or recurring job
    Start onStart on <今天的日期 ><today's-date> 作业的开始日期The job's start date
    Recur everyRecur every 1 小时 1 Hours 执行间隔和频率The recurrence interval and frequency
    EndEnd 结束日期:从今天起两天后的日期End by two days from today's date 作业的结束日期The job's end date
    UTC offsetUTC offset UTC +08:00 UTC +08:00 协调世界时 (UTC) 与所在位置的观察时间之间的时差The difference in time between Coordinated Universal Time (UTC) and your location's observed time

    定义计划

  6. 准备就绪后,选择“创建”。 When you're ready, choose Create.

    创建作业后,Azure 会部署作业,该作业将显示在 Azure 仪表板上。After you create your job, Azure deploys your job, which appears on the Azure dashboard.

  7. 当 Azure 显示部署成功的通知时,请选择“固定到仪表板” 。When Azure shows a notification that deployment succeeded, choose Pin to dashboard. 或者,请在 Azure 工具栏上选择“通知”图标(铃铛),然后选择“固定到仪表板” 。Otherwise, choose the Notifications icon (bell) on the Azure toolbar, and then choose Pin to dashboard.

监视和管理作业Monitor and manage jobs

要查看、监视和管理工作,请在 Azure 仪表板上选择作业。To review, monitor, and manage your job, on the Azure dashboard, choose your job. 在“设置”下,可以查看和管理作业的区域如下: Under Settings, here are the areas you can review and manage for your job:

作业设置

有关这些区域的详细信息,请选择一个区域:For more information about these areas, select an area:

属性Properties

要查看描述作业的管理元数据的只读属性,请选择“属性” 。To view read-only properties that describe the management metadata for your job, select Properties.

查看作业属性

操作设置Action settings

要更改作业的高级设置,请选择“操作设置” 。To change your job's advanced settings, select Action settings.

查看操作设置

操作类型Action type 说明Description
所有类型All types 可以更改“重试策略”和“错误操作”设置 。You can change the Retry policy and the Error action settings.
HTTP 和 HTTPSHTTP and HTTPS 可以将“方法”更改为任何允许的方法 。You can change Method to any permitted method. 还可以添加、删除或更改标头及基本身份验证信息。You can also add, delete, or change the headers and basic authentication information.
存储队列Storage queue 可以更改存储帐户、队列名称、SAS 令牌和正文。You can change the storage account, queue name, SAS token, and body.
服务总线Service Bus 可以更改命名空间、主题或队列路径、身份验证设置、传输类型、消息属性和消息正文。You can change the namespace, topic or queue path, authentication settings, transport type, message properties, and message body.

计划Schedule

如果通过作业向导设置了计划,则可以更改该计划,例如开始日期和时间、定期计划以及定期作业的结束日期和时间。If you set up a schedule through the job wizard, you can change that schedule, such as the start date and time, recurrence schedule, and the end date and time for recurring jobs. 可以构建更多复杂的计划和高级的定期计划You can also build more complex schedules and advanced recurrences.

要更改视图,或更改作业的计划,请选择“计划”: To change view or change your job's schedule, select Schedule:

查看作业计划

历史记录History

要查看有关所选作业每次运行的指标,请选择“历史记录” 。To view metrics about every run for a selected job, select History. 这些指标能提供有关作业健康状况的实时值,例如状态、重试次数、发生次数、开始时间和结束时间。These metrics provide real-time values about your job's health, such as status, number of retries, number of occurrences, start time, and end time.

查看作业历史记录和指标

要查看每次运行的历史记录详细信息,例如每次运行的完整响应,请在“历史记录”下选择每次运行 。To view the history details for each run, such as the complete response for each run, under History, select each run.

查看作业历史记录详细信息

用户Users

可以使用 Azure 基于角色的访问控制 (RBAC) 在粒度级别管理每个用户对 Azure 计划程序的访问。You can manage access to Azure Scheduler for each user at a granular level by using Azure Role-Based Access Control (RBAC). 要了解如何根据角色设置访问权限,请参阅使用 RBAC 管理访问权限To learn how to set up access based on roles, see Manage access using RBAC

后续步骤Next steps