快速入门:使用 Azure 逻辑应用创建第一个自动化工作流 - Azure 门户Quickstart: Create your first automated workflow with Azure Logic Apps - Azure portal

本快速入门介绍如何使用 Azure 逻辑应用构建第一个自动化工作流。This quickstart introduces how to build your first automated workflow with Azure Logic Apps. 在本文中,请创建一个逻辑应用,以便定期查看网站的 RSS 源中是否有新项。In this article, you create a logic app that regularly checks a website's RSS feed for new items. 如果存在新项,逻辑应用会针对每个项发送电子邮件。If new items exist, the logic app sends an email for each item. 完成后,逻辑应用看起来大致与以下工作流类似:When you're done, your logic app looks like this workflow at a high level:

概述 - 逻辑应用示例

若要按照本快速入门进行操作,你需要逻辑应用支持的提供商(例如 Office 365 Outlook、Outlook.com 或 Gmail)提供的电子邮件帐户。To follow this quickstart, you need an email account from a provider that's supported by Logic Apps, such as Office 365 Outlook, Outlook.com, or Gmail. 至于其他提供商,请查看此处的连接器列表For other providers, review the connectors list here. 此逻辑应用使用 Office 365 Outlook 帐户。This logic app uses an Office 365 Outlook account. 如果使用其他电子邮件帐户,整个步骤仍然是相同的,但 UI 可能稍有不同。If you use another email account, the overall steps are the same, but your UI might slightly differ.

另外,如果没有 Azure 订阅,请注册一个 Azure 试用帐户Also, if you don't have an Azure subscription, sign up for a trial Azure account.

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

使用 Azure 帐户凭据登录到 Azure 门户Sign in to the Azure portal with your Azure account credentials.

创建逻辑应用Create your logic app

  1. 在 Azure 主菜单中,选择“创建资源” > “集成” > “逻辑应用” 。From the main Azure menu, choose Create a resource > Integration > Logic App.


  2. 在“创建逻辑应用”下,提供有关逻辑应用的详细信息,如下所示。 Under Create logic app, provide details about your logic app as shown here. 完成后,选择“创建” 。After you're done, choose Create.


    属性Property Value 说明Description
    名称Name <logic-app-name><logic-app-name> 逻辑应用名称,只能包含字母、数字、连字符 (-)、下划线 (_)、括号(())和句点 (.)。Your logic app name, which can contain only letters, numbers, hyphens (-), underscores (_), parentheses ((, )), and periods (.). 此示例使用“My-First-Logic-App”。This example uses "My-First-Logic-App".
    订阅Subscription <Azure-subscription-name><Azure-subscription-name> Azure 订阅名称Your Azure subscription name
    资源组Resource group <Azure-resource-group-name><Azure-resource-group-name> 用于组织相关资源的 Azure 资源组的名称。The name for the Azure resource group used to organize related resources. 此示例使用“My-First-LA-RG”。This example uses "My-First-LA-RG".
    LocationLocation <Azure-region><Azure-region> 用于存储逻辑应用信息的区域。The region where to store your logic app information.
    Log AnalyticsLog Analytics 关闭Off 对于诊断日志记录,请保留“关闭”设置。 Keep the Off setting for diagnostic logging.
  3. 在 Azure 部署你的应用后,在 Azure 工具栏上,选择“通知” > “转到资源” ,查看你部署的逻辑应用。After Azure deploys your app, on the Azure toolbar, select Notifications > Go to resource for your deployed logic app.


    或者,可以通过在搜索框中键入名称来查找和选择逻辑应用。Or, you can find and select your logic app by typing the name in the search box.

    逻辑应用设计器打开并显示一个包含简介视频和常用触发器的页面。The Logic Apps Designer opens and shows a page with an introduction video and commonly used triggers. 在“模板”下选择“空白逻辑应用”。Under Templates, select Blank Logic App.


接下来请添加一个触发器,该触发器在出现新的 RSS 源项时触发。Next, add a trigger that fires when a new RSS feed item appears. 每个逻辑应用都必须从触发器开始,该触发器在发生特定事件或特定条件得到满足的情况下触发。Every logic app must start with a trigger, which fires when a specific event happens or when a specific condition is met. 每当触发器触发时,逻辑应用引擎就会创建一个逻辑应用实例来启动并运行工作流。Each time the trigger fires, the Logic Apps engine creates a logic app instance that starts and runs your workflow.

使用触发器检查 RSS 源Check RSS feed with a trigger

  1. 在逻辑应用设计器的搜索框下,选择“全部” 。In Logic App Designer, under the search box, select All.

  2. 在搜索框中输入“rss”。In the search box, enter "rss". 从触发器列表中选择此触发器:当有源项发布时 - RSSFrom the triggers list, select this trigger: When a feed item is published - RSS

    选择触发器:“RSS - 发布源项时”

  3. 为触发器提供如下所示的信息:Provide this information for your trigger as shown and described here:

    使用 RSS 源、频率和间隔设置触发器

    属性Property Value 说明Description
    RSS 源 URLThe RSS feed URL http://feeds.reuters.com/reuters/topNews 要监视的 RSS 源的链接The link for the RSS feed that you want to monitor
    时间间隔Interval 11 在两次检查之间需等待的时间间隔数The number of intervals to wait between checks
    频率Frequency 分钟Minute 两次检查的间隔的时间单位The unit of time for each interval between checks

    时间间隔和频率合在一起,即可定义逻辑应用的触发器的计划。Together, the interval and frequency define the schedule for your logic app's trigger. 此逻辑应用每分钟检查一次源。This logic app checks the feed every minute.

  4. 若要立即隐藏触发器详细信息,请单击触发器的标题栏。To hide the trigger details for now, click inside the trigger's title bar.


  5. 保存逻辑应用。Save your logic app. 在设计器工具栏上,选择“保存” 。On the designer toolbar, select Save.

逻辑应用现已生成,但除了检查 RSS 源,不能执行任何操作。Your logic app is now live but doesn't do anything other than check the RSS feed. 因此,请添加一项在触发器触发时进行响应的操作。So, add an action that responds when the trigger fires.

使用操作发送电子邮件Send email with an action

现在请添加一项操作,在 RSS 源中出现新项时发送电子邮件。Now add an action that sends email when a new item appears in the RSS feed.

  1. 在“发布源项时”触发器下,选择“新建步骤” 。Under the When a feed item is published trigger, choose New step.


  2. 在“选择操作”和搜索框下,选择“全部” 。Under Choose an action and the search box, choose All.

  3. 在搜索框中,输入“发送电子邮件”。In the search box, enter "send an email". 从操作列表中,为所需的 电子邮件提供商选择“发送电子邮件”操作。From the actions list, select the "send an email" action for the email provider that you want.

    选择此操作:“Office 365 Outlook - 发送电子邮件”

    若要通过对操作列表进行筛选来查找特定的应用或服务,可以先选择应用或服务:To filter the actions list to a specific app or service, you can select that app or service first:

    • 对于 Azure 工作或学校帐户,请选择“Office 365 Outlook”。For Azure work or school accounts, select Office 365 Outlook.
    • 对于个人 Microsoft 帐户,请选择“Outlook.com”。For personal Microsoft accounts, select Outlook.com.
  4. 如果系统要求提供凭据,请登录电子邮件帐户,这样逻辑应用就可以创建到该电子邮件帐户的连接了。If asked for credentials, sign in to your email account so that Logic Apps creates a connection to your email account.

  5. 在“发送电子邮件”操作中,指定需要电子邮件包括的数据。 In the Send an email action, specify the data that you want the email to include.

    1. 在“收件人” 框中,输入收件人的电子邮件地址。In the To box, enter the recipient's email address. 为进行测试,可以使用自己的电子邮件地址。For testing purposes, you can use your own email address.

      现在,请忽略出现的“添加动态内容”列表。 For now, ignore the Add dynamic content list that appears. 单击某些编辑框时,此列表会出现并显示前一步骤中提供的参数,这样即可将其作为工作流的输入包括进去。When you click inside some edit boxes, this list appears and shows any available parameters from the previous step that you can include as inputs in your workflow.

    2. 在“主题”框中,输入带有尾随空格的以下文本: New RSS item:In the Subject box, enter this text with a trailing blank space: New RSS item:


    3. 从“添加动态内容”列表 中选择“源标题” ,用于包括 RSS 项标题。From the Add dynamic content list, select Feed title to include the RSS item title.

      动态内容列表 -“源标题”

      完成后,电子邮件主题如以下示例所示:When you're done, the email subject looks like this example:


      如果“For each”循环显示在设计器上,则你为数组选择了一个令牌,例如 categories-Item 令牌。If a "For each" loop appears on the designer, then you selected a token for an array, for example, the categories-Item token. 对于这些类型的令牌,设计器会自动围绕引用该令牌的操作添加此循环。For these kinds of tokens, the designer automatically adds this loop around the action that references that token. 这样一来,逻辑应用会对每个数组项执行同一操作。That way, your logic app performs the same action on each array item. 若要删除循环,请选择循环的标题栏上的省略号 ( ... ),然后选择“删除”。 To remove the loop, choose the ellipses (...) on the loop's title bar, then choose Delete.

    4. 在“正文”框中选择此文本,然后选择这些令牌作为电子邮件正文。 In the Body box, enter this text, and select these tokens for the email body. 若要在编辑框中添加空行,请按 Shift + Enter。To add blank lines in an edit box, press Shift + Enter.


      属性Property 说明Description
      源标题 Feed title 项的标题The item's title
      源发布日期Feed published on 项的发布日期和时间The item's publishing date and time
      源主链接 Primary feed link 项的 URLThe URL for the item
  6. 保存逻辑应用。Save your logic app.

接下来,测试逻辑应用。Next, test your logic app.

运行逻辑应用Run your logic app

若要手动启动逻辑应用,可在设计器工具栏中选择“运行” 。To manually start your logic app, on the designer toolbar bar, choose Run. 或者,等待逻辑应用根据指定的计划(每隔一分钟)检索 RSS 源。Or, wait for your logic app to check the RSS feed based on your specified schedule (every minute). 如果 RSS 源有新项,逻辑应用会为每个新项发送一封电子邮件。If the RSS feed has new items, your logic app sends an email for each new item. 否则,逻辑应用会等到下一个间隔过后才进行检查。Otherwise, your logic app waits until the next interval before checking again.

例如,下面是此逻辑应用发送的一封示例电子邮件。For example, here is a sample email that this logic app sends.

针对新的 RSS 源项发送的电子邮件

从技术上讲,当触发器检查 RSS 源并找到新项时,触发器将会激发,并且逻辑应用引擎会创建一个逻辑应用工作流实例,用于运行工作流中的操作。Technically, when the trigger checks the RSS feed and finds new items, the trigger fires, and the Logic Apps engine creates an instance of your logic app workflow that runs the actions in the workflow. 如果触发器未找到新项,则触发器不会激发,而是“跳过”实例化工作流的操作。If the trigger doesn't find new items, the trigger doesn't fire and "skips" instantiating the workflow.

祝贺你,现已使用 Azure 门户成功生成并运行了第一个逻辑应用!Congratulations, you've now successfully built and run your first logic app with the Azure portal!

清理资源Clean up resources

不再需要此示例时,删除包含你的逻辑应用和相关资源的资源组。When you no longer need this sample, delete the resource group that contains your logic app and related resources.

  1. 在 Azure 主菜单中,转到“资源组”,然后选择逻辑应用的资源组。 On the main Azure menu, go to Resource groups, and select your logic app's resource group. 在“概述” 页面上,选择“删除资源组”。 On the Overview page, choose Delete resource group.


  2. 输入资源组名称作为确认,然后选择“删除”。 Enter the resource group name as confirmation, and select Delete.



删除逻辑应用后,任何新运行都不会实例化。When you delete a logic app, no new runs are instantiated. 所有正在进行和挂起的运行都将取消。All in-progress and pending runs are canceled. 如果有成千上万个运行,取消操作可能需要很长时间才能完成。If you have thousands of runs, cancellation might take significant time to complete.

获取支持Get support

有关问题,请访问 Azure 逻辑应用论坛For questions, visit the Azure Logic Apps forum.

后续步骤Next steps