Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Build and Release Pipelines for Azure Resources (Logic Apps and Azure Functions)

Post Author: Joe D365 |

Today’s blogpost is lengthy but should serve as a fantastic resource going forward. We will explore Build and Release Pipelines for Azure Resources as follows:

  1. Introduction
  2. Creating a build pipeline
  3. Creating a release pipeline
  4. Task Groups
  5. Library
  6. Logic App parameters

Enjoy (and bookmark!)

1. Introduction

Azure Pipelines is a fully featured continuous integration (CI) and continuous delivery (CD) service. Azure Pipelines helps you implement a build, test, and deployment pipeline for any software stack.

In the scenario below, we will be creating a build and a release pipeline in Azure DevOps that use one parameterized task group for deploying Azure Logic Apps and Functions to different environments.

The key benefit of using the approach we are describing below is that we are able to support deployment to multiple environments using a single list of tasks by leveraging task groups and variable groups from Azure DevOps. In other words, if we need to include one additional task (e.g. a new Logic App or a new Azure Function), we only need to change one thing – the task group. The high-level workflow is shown in the following diagram:

2. Create Build pipeline

  • Sign into the Azure DevOps project
  • Navigate to Pipelines > Builds > New > New build pipeline

  • In our case, our code resides at Team Foundation Version Control.

  • Browse and select the Server path (the source code path). Click Ok and Continue.

  • Select the right template. In our case, Azure Web App for ASP.Net and hit Apply.

  • Remove unwanted tasks in the pipeline or add tasks as per your requirement. In our case, I am removing the task Azure App Service Deploy.

  • Name the Build Pipeline and navigate to Triggers tab and select Path specification. Enable continuous integration will trigger the build for every check-in. Enabling Gated check-in will allow the code commit only after successful build.

Note: In case, if your node has Azure functions. Add a Build Solution task for each Azure Function App.

  • Click Save & queue, leave select folder and provide appropriate comment and hit Save.

  • Now your build pipeline is ready.

  • Whenever code is checked in. Build Pipeline will be triggered. Every build has unique name and with comments developer has provided while check in. We can Queue a new build using button Queue.

  • We can select a build instance and troubleshoot in case of any errors. We can create Release instantly using Release button. The Release will be created automatically with existing Build instance.

3. Create Release Pipeline

Release Pipeline enables to deploy the resources to target.

Navigate to Pipelines > Release > New > New Release Pipeline

  • Click on Add an artifact and select the Source (build pipeline) which we have created earlier from the dropdown and set Default version to Latest and hit Add.

  • We can schedule the trigger by clicking Schedule not set or invoke the trigger when the build is succeeded by Clicking on Continuous deployment trigger.

  • In our case we invoke the trigger whenever a build a succeeded. Click on bolt icon and enable the trigger. When the trigger is enabled, a tick mark will be shown next to bolt icon.

  • Click on Add a stage and Select a template and hit Apply. In our case template is, Azure App Service deployment.

  • Click on Tasks for the Stage 3 (you can rename the Stage 3). Remove the existing task and Add Azure resource group deployment Task.

  • Set the below properties.

1. Display name: Azure Deployment:Deploy POGetCustomerGroups LogicApp

2. Azure subscription: Select your subscription and authenticate. A Service Principle will be created. As I have already authenticated earlier, a Service Principle was created. So, I have used the existing Service Principle.

3. Action: Create or update resource group

4. Resource group: Select the resource group you want to deploy the Logic App.

5. Location: Select the Resource group location.

6. Template location: linked artifact

7. Template: $(System.DefaultWorkingDirectory)/_POTraining-AzureResources-CI/drop/POGetCustomerGroups/LogicApp.json

8. Template parameters: $(System.DefaultWorkingDirectory)/_POTraining-AzureResources-CI/drop/POGetCustomerGroups/LogicApp.parameters.json

9. We can define environment specific parameter files and select right one deploy to respective environment or else we can do achieve this using the Variable groups. Please refer section 5 (Libraries).

10. Click on Ellipse to Override template parameters. You can modify the default values provided in the Logic App. Click Ok to save the changes.

11. Make sure to use Key vault secret wherever possible. In our case we need Application Id and Secret to authenticate D365FO application. Instead of providing the hard coded value, we can provide the Key vault name which holds the actual ‘Secret’ required for authentication.

12. Deployment mode: Incremental

  • Add the task Azure App Service deploy to deploy Azure Function App.

  • Select the right Azure subscription (As you have already authenticated while creating Logic App Task, a Service Principle has created. Use the same Service Principle to authenticate.). Set App Service type to Function App on Windows and select App service name from the drop down. Leave the rest of the properties to default.

Note: Service Principals are specific to Resource group. We need create one for Resource group.

4. Task Groups

Based on our topology, we might have different resource groups. Each Resource group should have a Release Pipelines (or Stages). So, in case a Logic App or Azure Function App is developed. We need to add the resource as Task in the Pipeline. In order to avoid this redundancy work for all the resource groups. For better reusability, we can make use of Task groups.

We will Create Task groups, one for each Logic Apps and Azure functions and define the scope of the Variables in Release Pipeline. Let us create Task Group.

Note: we could put all Logic Apps and Functions together in one task group, but the list looks better organised if they are split when having 20+ of each resource type.

  • Name the Task group and Description and click OK. Task group will be created and replaces the existing Logic App Task. We can find the Task groups under Task groups.

  • Create one more Task group for Azure Function App. Now our Release Pipeline will look as below.

  • Save the Release Pipeline by clicking Save button and provide the appropriate comments and click OK.
  • Navigate to Task groups, the Task groups created earlier will be shown.

  • We can add Tasks to the Task groups using Plus icon.

5. Library

The values might differ from environment to environment (here I am referring to AX application and Resource groups). To differ the values from RG to RG (Resource group). We need to define variable groups and define the scope of the variable in Release Pipeline (Please refer Release Pipeline section, we define scope (resource group) while creating Release Pipeline.

  • Navigate to Library and click on plus symbol to create a new Resource group.

  • Provide Variable group name and Description. Click Add button to add variables to the group. After adding the variables hit Save button.

  • We need to replace the values with variables in Task groups. Navigate Azure Logic Apps Task group and replace with variables and hit Save button.

  • Now, it’s time to define variable scope in Release Pipeline. Navigate to Release Pipeline which we have created earlier and click on Edit button. Go to Variables tab and select the variable groups and link variable group.

  • Hit Save and provide Comment. Now Release Pipeline is ready for Continuous deployments. When a developer checks in the code, the Build Pipeline will be invoked and upon successful build, Release Pipeline will be invoked. We can check the list of the Releases and we can create an instant Release by clicking Create release button and select specific version of the build.

  • We can check the status and tasks performed during the course of the Release by selecting any particular Release instance.

6. Logic App parameters

Be aware of the three different places where parameters are stored in the ARM template that holds the code behind a Logic App. There are three places in the JSON where parameters are specified:

1. The ARM template parameter definition (child of the root node) – Line 38 below

2. The workflow parameter definition (child of node resources > properties) – Line 60 below

3. The workflow parameter initialisation (child of node resources) – Line 68 below

The first two parameters are just definitions, so they do not specify values, just the type, default value and a few others are valid fields. The value of a parameter will be specified in the third place, the initialisation under node resources. The normal practice is to initialise the value of the workflow parameters from the ARM template parameter values.

The ARM template parameter values can be specified in the separate parameter file (LogicApp.parameters.json) and can be overridden from the release pipeline.

References

https://docs.microsoft.com/en-us/azure/devops/pipelines/?toc=%2Fazure%2Fdevops%2Fpipelines%2Ftoc.json&bc=%2Fazure%2Fdevops%2Fboards%2Fpipelines%2Fbreadcrumb%2Ftoc.json&view=azure-devops

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

Leave a Reply

Your email address will not be published. Required fields are marked *

PowerObjects Recommends