我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

huangapple go评论68阅读模式
英文:

How Can We Deploy an Azure Logic App (Consumption Plan) to Azure Using DevOps?

问题

我们一直在寻找有关如何使用DevOps管道将Azure Logic App(消耗计划)部署到Azure Cloud的教程,甚至在Stack上找到了一些与这个问题类似的帖子,但似乎没有直接的方法来实现这一点。

我们最初在Azure Portal中直接开发了Logic App,希望可以从Azure Cloud下载Logic App,在开发机器上进行修改,然后提交到DevOps并重新部署到Azure Cloud。

为了测试这一点,我们在Visual Studio 2019项目中创建了一个新的Azure资源组项目。

并选择了Logic App:

此时,我们有一个新的解决方案,包含3个文件

  1. Deploy-AzureResourceGroup.ps1
  2. LogicApp.json
  3. LogicApp.parameters.json

由于我们已经在Azure Cloud中开发了Logic App,所以想法是下载已完成的Logic App,并将其添加/替换(现有文件)到/在这个解决方案中,但是下载的文件没有分成两个文件,即LogicApp.parameters.json和LogicApp.json,并且命名为其他名称,即testLogicApp.json。

我们不确定下载的文件(testLogicApp.json)是否需要修改/重命名并拆分为一个LogicApp.parameters.json文件和一个LogicApp.json文件,以替换现有的2个文件。

我们面临的下一个问题是如何使用DevOps部署Logic App。

对于这两种可能的解决方案,似乎至少有两种选择:

  1. 使用现有的Deploy-AzureResourceGroup.ps1
  2. 使用ARM模板

但是有关实施这两种可能解决方案的详细信息似乎难以找到,因此我们想知道是否有人可以在此之前经历过这个过程,是否能提供帮助。

提前感谢。

英文:

We have been searching for tutorials on how to deploy an Azure Logic App (Consumption Plan) to Azure Cloud using a DevOps pipeline and have even found some posts similar to this question here on Stack, but there doesn't seem to be a straightforward way to do this.

We originally developed the Logic App directly in Azure Portal are hoping we can download the Logic App from Azure Cloud and modify on a development machine, check into DevOps and deploy back up to the Azure Cloud.

To test this we created a new Azure Resource Group project in Visual Studio 2019 project.

我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

And chose Logic App:
我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

At this point we have a new solution with 3 files

  1. Deploy-AzureResourceGroup.ps1
  2. LogicApp.json
  3. LogicApp.parameters.json

我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

Since we already have developed the Logic App in Azure Cloud, the thought was to download the finished Logic App and add/replace (existing file) to/in this solution however the downloaded file isn't split into 2 files IE: LogicApp.parameters.json and LogicApp.json and is named something else IE: testLogicApp.json.

我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

We're not sure if the downloaded file (testLogicApp.json) needs to modified/renamed and split into a LogicApp.parameters.json file and a LogicApp.json file replacing the existing 2 files.

The next issue we're facing is how to deploy the Logic App using DevOps.

There seem to be at least 2 options for this which are:

  1. Use the existing Deploy-AzureResourceGroup.ps1
  2. Use an ARM Template

But details regarding implementing these 2 possible solutions seem to be difficult to find so we're wondering if anyone might be able to assist. if they've been through this process before.

Thanks in advance.

答案1

得分: 1

方法 1 - Azure 门户

  1. 通过门户设计器创建逻辑应用(我相信您已完成此步骤)
  2. 注意任何在开发过程中创建的 API 连接,可以在这里找到:我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?
  3. 一旦您已在开发环境中测试了逻辑应用并且一切按预期工作,您可以开始处理 ARM 模板。以下是如何轻松导出您的资源:我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?
  4. 根据您的逻辑应用,此时您可能需要添加一些额外的参数,如 subscriptionID 或 resourceGroupName,以便通过 ARM 模板部署进行设置。一旦您认为您的 ARM 模板可以使用(应仅需要进行轻微调整),然后您可以点击导出窗口顶部的“添加到库”按钮,选择模板规范的存储位置 我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?
  5. 您现在拥有一个 ARM 模板部署库,可用于部署到任何您希望的环境(如果您有权限),只需导航到您保存它的资源组中的模板规范。然后点击“部署”,这将显示订阅、资源组、区域和要部署的参数。我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

注意:这实际上与逻辑应用无关,几乎可以用于任何 Azure 资源。您也可以选择使用 Azure DevOps 或 Git 来执行对 Azure 资源组的 ARM 模板部署。您只需在存储库中使用 ARM 模板 JSON 文件,并可以在发布流程中设置参数覆盖值。

方法 2 - Azure DevOps

注意 - 我假设您正在使用 Visual Studio 来开发您的逻辑应用和代码,并且还集成了 Azure DevOps(或 Git)。

  1. 确保将您的 ARM 模板和参数文件从本地 Visual Studio 存储库推送到 Azure DevOps 或 Git 中。(以便两个文件都在远程存储库中可用)我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

  2. 在发布流程中使用这些文件作为工件 我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

  3. 下一步是创建您的 ARM 模板部署任务,并从工件中设置文件路径并填写覆盖参数。这是您将指定 ARM 模板部署的位置(订阅、资源组、位置等)以及要使用的参数值的地方:我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure? 此示例使用的是经典流水线编辑器,但以下是任务的 YAML 示例:

steps:
- task: AzureResourceManagerTemplateDeployment@3
  displayName: 'ARM Template deployment: Resource Group scope'
  inputs:
    azureResourceManagerConnection: 'SubsName (XXXX)'
    subscriptionId: 'XXXXXXXX'
    resourceGroupName: 'XXXXXXX'
    location: 'South Central US'
    csmFile: '$(System.DefaultWorkingDirectory)/_EDW-AzureResources/EDWResources/ADFErrorPollingLogicApp-template.json'
    csmParametersFile: '$(System.DefaultWorkingDirectory)/_EDW-AzureResources/EDWResources/ADFErrorPollingLogicApp-parameters.json'
    overrideParameters: '-workflows_adffailure_logic_app_name "logic-ccok-XXXX" -workflows_teamspost_logic_app_name "logic-ccok-XXXX" -environment "dev" -app_name "EDW" -teamsName "EDW-XXXXX" -teamsChannelName "ADF-DEVXXXX" -dataFactoryName "adf-cXXXX"'
英文:

Method 1 - Azure Portal

  1. Create the Logic App via the Portal Designer (I believe you have this step done)
  2. Take note of any API connections that have been created during your development, these can be found:我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?
  3. Once you have tested your Logic App in Dev and is working as expected, you can now work on the ARM Template. Here is how you can easily export your resources: 我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?
  4. Depending on your Logic App, at this point you may need to add some additional parameters like subscriptionID or resourceGroupName so that those can be set via the ARM Template Deployments. Once you believe your ARM template is good to go (should only require minor tweaks), then you can click the "Add to library" button at the top of Export window and choose where the Template Spec will reside 我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?
  5. You now have an ARM Template Deployment Library that can be used to deploy to any environment you wish (if you have the privileges), just navigate to the Template Spec at the Resource Group you saved it to. Then click "Deploy", this will bring up the Subscription, ResourceGroup, Region, and Parameters to deploy. 我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

**Note: This is really not specific to Logic Apps and can work with almost ANY Azure resource. You can alternatively use Azure DevOps or Git to do any ARM template deployments to an Azure resource group.You just need your ARM Template JSON file in the Repository and you can set your Parameter override values in the release pipeline.

Method 2 - Azure DevOps

*Note- I am making the assumption you are using Visual Studio to develop your Logic App and Code, which is also integrated with Azure DevOps (or Git).

  1. Make sure your ARM template and parameters file are pushed to Azure DevOps or Git from your local Visual Studio Repo. (So that both files are available in your Remote Repo) 我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

  2. Use these files as an Artifact in your Release Pipeline 我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure?

  3. The next step is to create your ARM Template Deployment Task and set the file paths from the artifact and fill out the override parameters. This is where you will specify where is the ARM Template deployment deploying to (Subscription, Resource Group, Location, etc) and what parameter values to use: 我们如何使用DevOps将Azure逻辑应用(消耗计划)部署到Azure? This particular example is using Classic Pipeline editor, but here is the yaml for the task:

    steps:
    - task: AzureResourceManagerTemplateDeployment@3
     displayName: 'ARM Template deployment: Resource Group scope'
     inputs:
       azureResourceManagerConnection: 'SubsName (XXXX)'
       subscriptionId: 'XXXXXXXX'
       resourceGroupName: 'XXXXXXX'
       location: 'South Central US'
       csmFile: '$(System.DefaultWorkingDirectory)/_EDW-AzureResources/EDWResources/ADFErrorPollingLogicApp-template.json'
    csmParametersFile: '$(System.DefaultWorkingDirectory)/_EDW-AzureResources/EDWResources/ADFErrorPollingLogicApp-parameters.json'
    overrideParameters: '-workflows_adffailure_logic_app_name "logic-ccok-XXXX" -workflows_teamspost_logic_app_name "logic-ccok-XXXX" -environment "dev" -app_name "EDW" -teamsName "EDW-XXXXX" -teamsChannelName "ADF-DEVXXXX" -dataFactoryName "adf-cXXXX"'
    

答案2

得分: 0

我通常使用这个提取器,效果很好,通过 PS-Gallery 安装很容易。

https://github.com/jeffhollan/LogicAppTemplateCreator

你可以运行:

Get-LogicAppTemplate -LogicApp MyApp -ResourceGroup myRg2023 -SubscriptionId 23d4ee89-xxxx-4bd3-a718-0050f2c8ab03 -Verbose | Out-File C:\template.json

获取单独的参数文件:

Get-ParameterTemplate -TemplateFile $filenname | Out-File 'paramfile.json'
英文:

I usually use this extractor, works great, installation is easy through PS-Gallery

https://github.com/jeffhollan/LogicAppTemplateCreator

you can run:

 Get-LogicAppTemplate -LogicApp MyApp -ResourceGroup myRg2023 -SubscriptionId 23d4ee89-xxxx-4bd3-a718-0050f2c8ab03 -Verbose | Out-File C:\template.json

and to get a separate param file:

Get-ParameterTemplate -TemplateFile $filenname | Out-File 'paramfile.json'

huangapple
  • 本文由 发表于 2023年5月7日 02:10:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76190403.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定