Archer Hume / Posts

CI/CD for Azure Logic Apps

October 17, 2023 • 3 min read

An abstract illustration representing Azure Logic Apps.

NOTE: This guide only works with consumption logic apps. Ensure the correct plan type is selected when creating the logic app resource.


Build Pipeline

When you create a Logic App using Visual Studio, you’ll typically have two files generated for your project: <Logic_App_Name>.json and <Logic_App_Name>.parameters.json. These files are Azure Resource Manager (ARM) templates, and both play a crucial role in the deployment process of your Logic App.

Configuration

Inside your <Logic_App_Name>.json file, you should have a parameters object. Here you will find all of the Logic App parameters that you will need to include in the <Logic_App_Name>.parameters.json file.

You should identify all of the parameters in the <Logic_App_Name>.json file and include them in the <Logic_App_Name>.parameters.json file with the following format:

NOTE: Do not include any sensitive details in this file as they will be included in the repository. You should set any sensitive values to an empty string or a placeholder value for the corresponding datatype. We will inject the actual values safely with the pipeline.

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "parameter-name": {
      "value": "parameter-value"
    },
  }
}

Setup

  1. Create the pipeline and choose a trigger.
  2. All you need to do is pull the ARM templates from the repository and publish them in the artifacts folder. Here is an example of what this looks like:
pool:
  vmImage: 'windows-2019'

jobs:
- job: logic_app_build
  displayName: 'Build and publish logic app'
  steps:
  - task: CopyFiles@2
    displayName: 'Create project folder'
    inputs:
      SourceFolder: '$(System.DefaultWorkingDirectory)/LogicApp/LogicApp'
      Contents: |
        LogicApp.json
        LogicApp.parameters.json
      TargetFolder: 'project_output'
  - task: PublishPipelineArtifact@1
    displayName: 'Publish project template artifact'
    inputs:
      targetPath: '$(System.DefaultWorkingDirectory)/project_output/'
      artifact: '$(logicAppCIArtifactName)'
      publishLocation: 'pipeline'

Release Pipeline

Now that we have the ARM templates as artifacts from the build pipeline, we need to inject any sensitive parameters that we removed in the earlier stage then deploy the templates to our Logic App resource.

Setup

  1. Create the release pipeline, and choose your initial pipeline as an artifact source.
  2. Add a new stage and select Empty Job from the templates.
  3. In the newly created stage, add an Agent Job.
  4. Click the plus on the new Agent Job, and choose ARM Template deployment
  5. You will need to create an Azure Resource Manager Connection and choose your Logic App resource.
  6. In the Template Settings section, you must select the templates from the artifacts and then override the template parameters with the sensitive parameter values. The sensitive values should be stored safely as variables in the pipeline.

If you have correctly followed the guide (provided Microsoft hasn’t made any breaking changes), you should now have a fully automated CI/CD pipeline for your Azure Logic App.

– Archer Hume