为 Azure 逻辑应用部署 Azure 资源管理器模板Deploy Azure Resource Manager templates for Azure Logic Apps

创建用于逻辑应用的 Azure 资源管理器模板后,可按以下方式部署该模板:After you create an Azure Resource Manager template for your logic app, you can deploy your template in these ways:

通过 Azure 门户进行部署Deploy through Azure portal

若要自动将逻辑应用模板部署到 Azure,可以选择下面的“部署到 Azure”按钮,这样可以登录到 Azure 门户,系统会提示你输入有关逻辑应用的信息。To automatically deploy a logic app template to Azure, you can choose the following Deploy to Azure button, which signs you in to the Azure portal and prompts you for information about your logic app. 然后,可对逻辑应用模板或参数进行任何必要的更改。You can then make any necessary changes to the logic app template or parameters.

部署到 Azure Deploy to Azure

例如,在登录到 Azure 门户后,系统会提示输入以下信息:For example, you're prompted for the following information after you sign in to the Azure portal:

  • Azure 订阅名称Azure subscription name
  • 要使用的资源组Resource group that you want to use
  • 逻辑应用位置Logic app location
  • 逻辑应用的名称The name for your logic app
  • 测试 URIA test URI
  • 接受指定的条款和条件Acceptance of the specified terms and conditions

有关详细信息,请参阅以下主题:For more information, see these topics:

使用 Visual Studio 进行部署Deploy with Visual Studio

若要从使用 Visual Studio 创建的 Azure 资源组项目部署逻辑应用模板,请按这些步骤操作,将逻辑应用手动部署到 Azure。To deploy a logic app template from an Azure Resource Group project that you created by using Visual Studio, follow these steps to manually deploy your logic app to Azure.

使用 Azure PowerShell 部署Deploy with Azure PowerShell

若要部署到特定的 Azure 资源组,请使用以下命令:To deploy to a specific Azure resource group, use the following command:

New-AzResourceGroupDeployment -ResourceGroupName <Azure-resource-group-name> -TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.logic/logic-app-create/azuredeploy.json

有关详细信息,请参阅以下主题:For more information, see these topics:

使用 Azure CLI 进行部署Deploy with Azure CLI

若要部署到特定的 Azure 资源组,请使用以下命令:To deploy to a specific Azure resource group, use the following command:

az deployment group create -g <Azure-resource-group-name> --template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.logic/logic-app-create/azuredeploy.json

有关详细信息,请参阅以下主题:For more information, see these topics:

使用 Azure DevOps 进行部署Deploy with Azure DevOps

若要部署逻辑应用模板并管理环境,团队通常会使用 Azure DevOps 中的 Azure Pipelines 等工具。To deploy logic app templates and manage environments, teams commonly use a tool such as Azure Pipelines in Azure DevOps. Azure Pipelines 提供一个可以添加到任何生成管道或发布管道的 Azure 资源组部署任务Azure Pipelines provides an Azure Resource Group Deployment task that you can add to any build or release pipeline. 若要授权部署和生成发布管道,还需要一个 Azure Active Directory (AD) 服务主体For authorization to deploy and generate the release pipeline, you also need an Azure Active Directory (AD) service principal. 详细了解如何在 Azure Pipelines 中使用服务主体Learn more about using service principals with Azure Pipelines.

若要详细了解如何使用 Azure Pipelines 进行与 Azure 资源管理器模板相对应的持续集成和持续部署 (CI/CD),请参阅以下主题和示例:For more information about continuous integration and continuous deployment (CI/CD) for Azure Resource Manager templates with Azure Pipelines, see these topics and samples:

下面是有关使用 Azure Pipelines 的一般性概要步骤:Here are the general high-level steps for using Azure Pipelines:

  1. 在 Azure Pipelines 中创建空管道。In Azure Pipelines, create an empty pipeline.

  2. 选择管道所需的资源,例如,手动生成的或者在生成过程中生成的逻辑应用模板和模板参数文件。Choose the resources you need for the pipeline, such as your logic app template and template parameters files, which you generate manually or as part of the build process.

  3. 对于代理作业,请找到并添加“Azure 资源组部署”任务。For your agent job, find and add the Azure Resource Group Deployment task.

    添加“Azure 资源组部署”任务

  4. 使用服务主体进行配置。Configure with a service principal.

  5. 添加对逻辑应用模板和模板参数文件的引用。Add references to your logic app template and template parameters files.

  6. 继续在发布过程中根据需要为其他任何环境、自动测试或审批程序构建步骤。Continue to build out steps in the release process for any other environment, automated test, or approvers as needed.

授权 OAuth 连接Authorize OAuth connections

部署后,逻辑应用将使用有效的参数完成端到端工作。但是,若要生成用于验证凭据的有效访问令牌,你仍然需要对 OAuth 连接授权,或使用预先授权的 OAuth 连接。After deployment, your logic app works end-to-end with valid parameters, but to generate valid access tokens for authenticating your credentials, you still have to authorize or use preauthorized OAuth connections. 不过,你只需要部署和验证 API 连接资源一次,这意味着你不必在后续部署中包括这些连接资源,除非你必须更新连接信息。However, you only have to deploy and authenticate API connection resources once, meaning you don't have to include those connection resources in subsequent deployments unless you have to update the connection information. 如果使用持续集成和持续部署管道,则只部署更新的逻辑应用资源,而不必每次都对连接重新授权。If you use a continuous integration and continuous deployment pipeline, you'd deploy only updated Logic Apps resources and don't have to reauthorize the connections every time.

以下是关于如何处理授权连接的一些建议:Here are a few suggestions to handle authorizing connections:

  • 在同一区域的逻辑应用中对 API 连接资源进行预授权和共享。Preauthorize and share API connection resources across logic apps that are in the same region. API 连接作为 Azure 资源独立于逻辑应用而存在。API connections exist as Azure resources independently from logic apps. 虽然逻辑应用依赖于 API 连接资源,但 API 连接资源不依赖于逻辑应用,在删除依赖的逻辑应用后仍然存在。While logic apps have dependencies on API connection resources, API connection resources don't have dependencies on logic apps and remain after you delete the dependent logic apps. 此外,逻辑应用可以使用其他资源组中存在的 API 连接。Also, logic apps can use API connections that exist in other resource groups. 但是,逻辑应用设计器支持仅在逻辑应用所在的资源组中创建 API 连接。However, the Logic App Designer supports creating API connections only in the same resource group as your logic apps.

    备注

    如果考虑共享 API 连接,请确保你的解决方案可以处理潜在的限制问题If you're considering sharing API connections, make sure that your solution can handle potential throttling problems. 限制发生在连接级别,因此在多个逻辑应用中重用同一连接可能会提高出现限制问题的可能性。Throttling happens at the connection level, so reusing the same connection across multiple logic apps might increase the potential for throttling problems.

  • 除非你的方案涉及需要多重身份验证的服务和系统,否则你可以使用 PowerShell 脚本为每个 OAuth 连接提供同意,方法是:在具有活动浏览器会话且已提供授权和同意的虚拟机上以普通用户帐户身份运行持续集成辅助角色。Unless your scenario involves services and systems that require multi-factor authentication, you can use a PowerShell script to provide consent for each OAuth connection by running a continuous integration worker as a normal user account on a virtual machine that has active browser sessions with the authorizations and consent already provided. 例如,可以重新调整逻辑应用 GitHub 存储库中的 LogicAppConnectionAuth 项目提供的示例脚本的用途。For example, you can repurpose the sample script provided by the LogicAppConnectionAuth project in the Logic Apps GitHub repo.

  • 若要对 OAuth 连接进行手动授权,请在 Azure 门户或 Visual Studio 的逻辑应用设计器中打开逻辑应用。Manually authorize OAuth connections by opening your logic app in Logic App Designer, either in the Azure portal or in Visual Studio.

  • 如果改用 Azure Active Directory (Azure AD) 服务主体来授权连接,请了解如何在逻辑应用模板中指定服务主体参数If you use an Azure Active Directory (Azure AD) service principal instead to authorize connections, learn how to specify service principal parameters in your logic app template.

后续步骤Next steps