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

概述 - 什么是 Azure 逻辑应用?Overview - What is Azure Logic Apps?

Azure 逻辑应用是一项云服务,用于在需要跨企业或组织集成应用、数据、系统和服务时计划、自动执行和协调任务、业务流程和工作流Azure Logic Apps is a cloud service that helps you schedule, automate, and orchestrate tasks, business processes, and workflows when you need to integrate apps, data, systems, and services across enterprises or organizations. 逻辑应用可简化可缩放解决方案的设计和生成方式,适用于应用集成、数据集成、系统集成、企业应用程序集成 (EAI) 和企业到企业 (B2B) 通信,不管是在云中还是在本地。Logic Apps simplifies how you design and build scalable solutions for app integration, data integration, system integration, enterprise application integration (EAI), and business-to-business (B2B) communication, whether in the cloud, on premises, or both.

例如,下面就是一些可以通过逻辑应用自动完成的工作负荷:For example, here are just a few workloads you can automate with logic apps:

  • 跨本地系统和云服务处理并路由订单。Process and route orders across on-premises systems and cloud services.

  • 当各种系统、应用和服务中发生活动时,使用 Office 365 发送电子邮件通知。Send email notifications with Office 365 when events happen in various systems, apps, and services.

  • 将上传的文件从 SFTP 或 FTP 服务器移至 Azure 存储。Move uploaded files from an SFTP or FTP server to Azure Storage.

  • 监视推文中的特定主题,分析观点,针对需要查看的项目创建警报或任务。Monitor tweets for a specific subject, analyze the sentiment, and create alerts or tasks for items that need review.

若要使用 Azure 逻辑应用生成企业集成解决方案,可以从一个不断扩充的库中进行选择。该库包含数百个可使用的连接器,包括各种服务,例如 Azure 服务总线、Azure Functions 和 Azure 存储、SQL Server、Office 365、Dynamics、Salesforce、BizTalk、SAP、Oracle DB、文件共享等。To build enterprise integration solutions with Azure Logic Apps, you can choose from a growing gallery with hundreds of ready-to-use connectors, which include services such as Azure Service Bus, Azure Functions, Azure Storage, SQL Server, Office 365, Dynamics, Salesforce, BizTalk, SAP, Oracle DB, file shares, and more. 连接器提供触发器和/或操作,所创建的逻辑应用可以安全地对数据进行实时访问和处理。Connectors provide triggers, actions, or both for creating logic apps that securely access and process data in real time.

逻辑应用的工作原理How do logic apps work?

每个逻辑应用工作流都从触发器开始,在发生特定事件或新的可用数据符合特定条件的情况下触发。Every logic app workflow starts with a trigger, which fires when a specific event happens, or when new available data meets specific criteria. 逻辑应用中的连接器提供的许多触发器都包含基本的计划功能,方便你设置工作负荷的运行频率。Many triggers provided by the connectors in Logic Apps include basic scheduling capabilities so that you can set up how regularly your workloads run. 对于更复杂的计划或高级重复周期,你可以使用重复触发器作为任何工作流的第一步。For more complex scheduling or advanced recurrences, you can use a Recurrence trigger as the first step in any workflow. 详细了解基于计划的工作流Learn more about schedule-based workflows.

每当触发器触发时,逻辑应用引擎就会创建一个逻辑应用实例来运行工作流中的操作。Each time that the trigger fires, the Logic Apps engine creates a logic app instance that runs the actions in the workflow. 这些操作也可包括数据转换和工作流控制,如条件语句、开关语句、循环和分支。These actions can also include data conversions and workflow controls, such as conditional statements, switch statements, loops, and branching. 例如,以下逻辑应用通过 Dynamics 365 触发器启动,带有内置的条件“当更新记录时”。For example, this logic app starts with a Dynamics 365 trigger with the built-in criteria "When a record is updated". 触发器在检测到与此条件匹配的事件时,会触发并运行工作流的操作。If the trigger detects an event that matches this criteria, the trigger fires and runs the workflow's actions. 在这里,这些操作包括 XML 转换、数据更新、决策分支和电子邮件通知。Here, these actions include XML transformation, data updates, decision branching, and email notifications.

逻辑应用设计器 - 示例逻辑应用

可以使用逻辑应用设计器直观地生成逻辑应用。该设计器可通过浏览器在 Azure 门户中获取,也可在 Visual Studio 中获取。You can build your logic apps visually with the Logic Apps Designer, which is available in the Azure portal through your browser and in Visual Studio. 若要获取更多的自定义逻辑应用,可以使用“代码视图”编辑器以 JavaScript 对象表示法 (JSON) 创建或编辑逻辑应用定义。For more custom logic apps, you can create or edit logic app definitions in JavaScript Object Notation (JSON) by working in the "code view" editor. 也可对选定的任务使用 Azure PowerShell 命令和 Azure 资源管理器模板。You can also use Azure PowerShell commands and Azure Resource Manager templates for select tasks. 逻辑应用部署和运行在 Azure 云中。Logic apps deploy and run in the cloud on Azure. 如需更详细的介绍,请观看此视频:使用 Azure Enterprise Integration Services 大规模运行云应用For a more detailed introduction, watch this video: Use Azure Enterprise Integration Services to run cloud apps at scale

使用逻辑应用的原因Why use logic apps?

随着企业逐渐转向数字化,逻辑应用应运而生。它可以提供预生成的 API 作为 Microsoft 托管的连接器,从而可以更轻松快捷地连接旧系统和新式、前沿的系统。With businesses moving toward digitization, logic apps help you connect legacy, modern, and cutting-edge systems more easily and quickly by providing prebuilt APIs as Microsoft-managed connectors. 因此,你可以专注于应用的业务逻辑和功能,That way, you can focus on your apps' business logic and functionality. 不需担心应用的生成、托管、缩放、管理、维护和监视。You don't have to worry about building, hosting, scaling, managing, maintaining, and monitoring your apps. 逻辑应用为你解决这一切。Logic Apps handles these concerns for you. 另外,只需根据使用情况付费,具体取决于使用量定价模型Plus, you pay only for what you use based on a consumption pricing model.

在许多情况下,无需编写代码。In many cases, you won't have to write code. 但如果必须编写一些代码,则可使用 Azure Functions 创建代码片段,然后通过逻辑应用按需运行该代码。But if you must write some code, you can create code snippets with Azure Functions and run that code on-demand from logic apps. 另外,如果逻辑应用需要与来自 Azure 服务、自定义应用或其他解决方案的事件交互,则可将 Azure 事件网格与逻辑应用配合使用,以便进行事件监视、路由和发布。Also, if your logic apps need to interact with events from Azure services, custom apps, or other solutions, you can use Azure Event Grid with your logic apps for event monitoring, routing, and publishing.

逻辑应用、Functions 和事件网格由 Microsoft Azure 全权托管,因此不必担心解决方案的生成、托管、缩放、管理、监视和维护。Logic Apps, Functions, and Event Grid are fully managed by Microsoft Azure, which frees you from worries about building, hosting, scaling, managing, monitoring, and maintaining your solutions. 由于能够创建“无服务器”应用和解决方案,因此只需关注业务逻辑。With the capability to create "serverless" apps and solutions, you can just focus on the business logic. 这些服务可以按需自动缩放,加快集成速度,使用最少的代码生成可靠的云应用。These services automatically scale to meet your needs, make integrations faster, and help you build robust cloud apps with minimal code.

若要了解公司如何将逻辑应用与其他 Azure 服务和 Microsoft 产品配合使用,以便增强敏捷性并更加专注于核心业务,请查看这些客户案例To learn how companies improved their agility and increased focus on their core businesses when they combined Logic Apps with other Azure services and Microsoft products, check out these customer stories.

下面更详细地介绍逻辑应用的功能和好处:Here are more details about the capabilities and benefits that you get with Logic Apps:

使用易用的工具直观地生成工作流Visually build workflows with easy-to-use tools

使用可视化设计工具,既节省时间,又能简化复杂的流程。Save time and simplify complex processes with visual design tools. 从头至尾使用逻辑应用设计器来生成逻辑应用,不管是通过浏览器在 Azure 门户中使用,还是在 Visual Studio 中使用。Build logic apps from start-to-finish by using the Logic Apps Designer through your browser in the Azure portal or in Visual Studio. 使用触发器启动工作流,并从连接器库添加任意数量的操作。Start your workflow with a trigger, and add any number of actions from the connectors gallery.

使用逻辑应用模板加快入门速度Get started faster with logic app templates

模板库选择预定义的工作流时,可以更快速地创建常用解决方案。Create commonly used solutions more quickly when you choose predefined workflows from the template gallery. 模板既有适用于软件即服务 (SaaS) 应用的简单连接,也有高级 B2B 解决方案,还有“兴趣型”模板。Templates range from simple connectivity for software-as-a-service (SaaS) apps to advanced B2B solutions plus "just for fun" templates. 了解如何从预生成的模板创建逻辑应用Learn how to create logic apps from prebuilt templates.

跨不同的环境连接不同的系统Connect disparate systems across different environments

某些模式和工作流描述起来容易,但难以在代码中实现。Some patterns and workflows are easy to describe but hard to implement in code. 逻辑应用可用于跨本地环境和云环境无缝连接不同的系统。Logic apps help you seamlessly connect disparate systems across on-premises and cloud environments. 例如,可以将云营销解决方案连接到本地计费系统,也可以使用企业服务总线集中进行跨 API 和系统的消息传送。For example, you can connect a cloud marketing solution to an on-premises billing system, or centralize messaging across APIs and systems with an Enterprise Service Bus. 可以通过逻辑应用快速、可靠且一致地为这些方案提供可重复使用和重新配置的解决方案。Logic apps provide a fast, reliable, and consistent way to deliver reusable and reconfigurable solutions for these scenarios.

针对企业集成和 B2B 方案的一流支持First-class support for enterprise integration and B2B scenarios

企业和组织使用符合行业标准但却不同的消息协议和格式(例如 EDIFACT、AS2 和 X12)进行电子方式的相互通信。Businesses and organizations electronically communicate with each other by using industry-standard but different message protocols and formats, such as EDIFACT, AS2, and X12. 可以使用 Enterprise Integration Pack (EIP) 中的功能来生成逻辑应用,以便将合作伙伴使用的消息格式转换成组织的系统能够解释和处理的格式。With the features in the Enterprise Integration Pack (EIP), you can build logic apps that transform message formats used by your partners into formats that your organization's systems can interpret and process. 逻辑应用可以通过加密和数字签名顺利且安全地处理这些交换。Logic Apps handles these exchanges smoothly and also securely with encryption and digital signatures.

一开始采用小规模,只需使用当前的系统和服务,然后按自己的步调逐渐扩大规模。Start small with your current systems and services, and grow incrementally at your own pace. 准备就绪以后,即可使用逻辑应用和 EIP 来获得以下功能和其他功能,从而实现集成方案并通过纵向扩展将其变为更成熟的方案:When you're ready, Logic Apps and the EIP help you implement and scale up to more mature integration scenarios by providing these capabilities and more:

例如,如果使用 Microsoft BizTalk Server,则逻辑应用可以使用 BizTalk Server 连接器与 BizTalk Server 通信。For example, if you're using Microsoft BizTalk Server, logic apps can communicate with your BizTalk Server by using the BizTalk Server connector. 然后,可以通过包含集成帐户连接器(已在 Enterprise Integration Pack 中提供),在逻辑应用中进行扩展或执行类似于 BizTalk 的操作。You can then extend or perform BizTalk-like operations in your logic apps by including integration account connectors, which are available with the Enterprise Integration Pack.

从另一个方向看,BizTalk Server 可以使用适用于逻辑应用的 Microsoft BizTalk Server 适配器连接到逻辑应用并与其通信。Going in the other direction, BizTalk Server can connect to and communicate with logic apps by using the Microsoft BizTalk Server Adapter for Logic Apps. 了解如何在 BizTalk Server 中设置和使用 BizTalk 服务器适配器Learn how to set up and use the BizTalk Server Adapter in your BizTalk Server.

编写一次即可多次重复使用Write once, reuse often

将逻辑应用创建为 Azure 资源管理器模板,以便可以跨多个环境和区域自动执行逻辑应用部署Create your logic apps as Azure Resource Manager templates so that you can automate logic app deployment across multiple environments and regions.

访问 Azure 虚拟网络中的资源Access resources inside Azure virtual networks

当你创建集成服务环境 (ISE) 时,逻辑应用可访问Azure 虚拟网络中的受保护资源,例如虚拟机 (VM) 以及其他系统或服务。Logic apps can access secured resources, such as virtual machines (VMs) and other systems or services, that are inside an Azure virtual network when you create an integration service environment (ISE). ISE 是逻辑应用服务的专用实例,该实例使用专用资源并独立于“全局”多租户逻辑应用服务运行。An ISE is a dedicated instance of the Logic Apps service that uses dedicated resources and runs separately from the "global" multi-tenant Logic Apps service.

在你自己的专用实例中运行逻辑应用有助于降低其他 Azure 租户对应用性能的影响,此影响也称为“邻近干扰”影响Running logic apps in your own separate dedicated instance helps reduce the impact that other Azure tenants might have on your apps' performance, also known as the "noisy neighbors" effect. ISE 还带来以下好处:An ISE also provides these benefits:

  • 你自己的静态 IP 地址,它们不同于多租户服务中的逻辑应用共享的静态 IP 地址。Your own static IP addresses, which are separate from the static IP addresses that are shared by the logic apps in the multi-tenant service. 还可以设置单个公共的、静态的和可预测的出站 IP 地址,以便与目标系统通信。You can also set up a single public, static, and predictable outbound IP address to communicate with destination systems. 这样就无需在每个 ISE 的那些目标系统上设置其他防火墙开口。That way, you don't have to set up additional firewall openings at those destination systems for each ISE.

  • 增加了对运行持续时间、存储保留、吞吐量、HTTP 请求和响应超时、消息大小和自定义连接器请求的限制。Increased limits on run duration, storage retention, throughput, HTTP request and response timeouts, message sizes, and custom connector requests. 有关详细信息,请参阅 Azure 逻辑应用的限制和配置For more information, see Limits and configuration for Azure Logic Apps.

当你创建 ISE 时,Azure 会将该 ISE 注入或部署到 Azure 虚拟网络中。When you create an ISE, Azure injects or deploys that ISE into your Azure virtual network. 然后,你可以将该 ISE 用作需要进行访问的逻辑应用和集成帐户的位置。You can then use this ISE as the location for the logic apps and integration accounts that need access. 若要详细了解如何创建 ISE,请参阅从 Azure 逻辑应用连接到 Azure 虚拟网络For more information about creating an ISE, see Connect to Azure virtual networks from Azure Logic Apps.

内置的扩展性Built-in extensibility

如果找不到所需的连接器以运行自定义代码,则可通过 Azure Functions 根据需要创建和调用自己的代码片段,从而扩展逻辑应用。If you don't find the connector that you want to run custom code, you can extend logic apps by creating and calling your own code snippets on-demand through Azure Functions. 创建自己的 API自定义连接器,以便通过逻辑应用对其进行调用。Create your own APIs and custom connectors that you can call from logic apps.

只需为使用的服务付费Pay only for what you use

逻辑应用使用基于使用情况的定价和计费,除非该逻辑应用是以前使用应用服务计划创建的。Logic Apps uses consumption-based pricing and metering unless you have logic apps previously created with App Service plans.

通过以下介绍性视频详细了解逻辑应用:Learn more about Logic Apps with these introductory videos:

逻辑应用与 Functions、WebJobs 及 Power Automate 的区别在哪里?How does Logic Apps differ from Functions, WebJobs, and Power Automate?

所有这些服务都可以用来将不同的系统“粘贴”和连接到一起。All these services help you "glue" and connect disparate systems together. 每项服务都有其优点和优势,因此若要快速生成可缩放且功能完备的集成系统,最好的方法是将这些服务的功能组合到一起。Each service has their advantages and benefits, so combining their capabilities is the best way to quickly build a scalable, full-featured integration system. 有关详细信息,请参阅在逻辑应用、Functions、WebJobs 和 Power Automate 之间进行选择For more information, see Choose between Logic Apps, Functions, WebJobs, and Power Automate.

关键术语Key terms

  • 工作流:以一系列步骤的方式完成业务流程的可视化、设计、生成、自动化和部署操作。Workflow: Visualize, design, build, automate, and deploy business processes as series of steps.

  • 托管连接器:逻辑应用需要访问数据、服务和系统。Managed connectors: Your logic apps need access to data, services, and systems. 可以使用预生成的 Microsoft 托管连接器,这些连接器旨在连接、访问和使用数据。You can use prebuilt Microsoft-managed connectors that are designed to connect, access, and work with your data. 请参阅适用于 Azure 逻辑应用的连接器See Connectors for Azure Logic Apps.

  • 触发器:许多 Microsoft 托管连接器提供的触发器可以在事件或新数据符合指定条件时触发。Triggers: Many Microsoft-managed connectors provide triggers that fire when events or new data meet specified conditions. 例如,某个事件可能正在获取电子邮件或检测 Azure 存储帐户中的更改。For example, an event might be getting an email or detecting changes in your Azure Storage account. 每当触发器触发时,逻辑应用引擎就会创建一个新的逻辑应用实例来运行工作流。Each time the trigger fires, the Logic Apps engine creates a new logic app instance that runs the workflow.

  • 操作:操作是在触发器之后发生的所有步骤。Actions: Actions are all the steps that happen after the trigger. 每个操作通常都会映射到由托管连接器、自定义 API 或自定义连接器定义的操作。Each action usually maps to an operation that's defined by a managed connector, custom API, or custom connector.

  • Enterprise Integration Pack:对于更高级的集成方案,逻辑应用会包括 BizTalk Server 中的功能。Enterprise Integration Pack: For more advanced integration scenarios, Logic Apps includes capabilities from BizTalk Server. Enterprise Integration Pack 提供的连接器可以帮助逻辑应用轻松地执行验证、转换等操作。The Enterprise Integration Pack provides connectors that help logic apps easily perform validation, transformation, and more.

入门Get started

逻辑应用是托管在 Microsoft Azure 上的许多服务之一。Logic Apps is one of the many services hosted on Microsoft Azure. 因此在开始之前,你需要一个 Azure 订阅。So before you start, you need an Azure subscription. 如果没有订阅,可以注册免费的 Azure 帐户If you don't have a subscription, sign up for a free Azure account.

如果有 Azure 订阅,可以尝试此创建第一个逻辑应用的快速入门。该逻辑应用通过 RSS 源监视网站上的新内容,在新内容出现时发送电子邮件。If you have an Azure subscription, try this quickstart to create your first logic app, which monitors new content on a website through an RSS feed and sends email when new content appears.

后续步骤Next steps