Blog Post

Azure Integration Services Blog
5 MIN READ

Deploying Logic App Standard resource through DevOps pipeline

Shree_Divya_M_V's avatar
Jun 23, 2022

In collaboration with Wagner Silveira

 

Automating the deployment of Logic Apps Standard through a CI/CD pipeline requires a different process from that used by Logic Apps Consumption. As Logic Apps Standard now encapsulates a group of workflows in a single unit of deployment (the Logic App Standard App), to fully automate the deployment process the following artefacts are required:

 

Infrastructure components

  • Logic Apps Standard App (including dependencies like App Service Plan and Storage accounts)
  • Managed Connectors (also known as Azure Connectors)

Code components

  • Workflows
  • Connection settings (connections.json)
  • Parameter settings (parameters.json)
  • Application settings configuration
  •  

There are a few things to consider when deploying Azure connectors (managed connectors).

 

1. Access policies:

Logic app resource requires permission to read the connection secrets from APIHUB to interact with connector backend.

In case of consumption logic app, this is implemented internally (Being a shared cloud service, Logic App’s service principal has these permissions to read connection secrets).

Whereas in the case of standard logic app, as runtime is hosted in customer’s environment, there is a need to explicitly add an access policy at Azure connection to add permissions for System assigned managed identity of Logic App.

To achieve this, in the Logic app ARM template we would be creating system managed identity for logic app, input this identity value to Connection creation ARM template and add access policy.

 

2. Connection runtime URL:

In Logic App Standard, the connections.json file would have a field called “connectionRuntimeUrl” that refers to the runtime URL of the azure connection being used. Hence while deploying workflows, it is important to retrieve the “connectionRuntimeUrl” from the azure connection which is deployed in the portal and apply it to the correct entry in connections.json file.

To achieve this, In the connection creation ARM template, we would push the connection runtime URL as an app setting and in connections.json, we would refer to this app setting.

 

Please refer to the diagram below and the reference article for more details on these concepts.

Set up DevOps for Standard logic apps - Azure Logic Apps | Microsoft Docs

 

 

 

 

 

Based on the above considerations, please find below the detailed steps for deploying a logic app and its workflows with all three types of connections (built-in/service provider connections, Azure connections and function connections).

 

Step 1 – Creating the Logic App infrastructure ARM template

 

In this template we add Logic app infrastructure resource and all the dependent resources like Storage Account, Application Insight, App service plan and VNET configurations. In this step we:

 

Step 2 – Creating the Managed connections ARM template

 

In this template, we would add Azure connection resources. This template would take inputs from the previous template and use them to create access policy for Logic App’s managed identity. In this step we:

  • Define the ARM template for the API connections to be used in the logic app
  • Add the access policy to provide access to Logic App’s managed identity.
  • Output the Connection Runtime URL

Example: LogicAppStandard/connectors-template.json at master · ShreeDivyaMV/LogicAppStandard (github.com)

 

Step 3 – Setup the Infrastructure as Code (IaC) pipeline

 

Once both templates (Logic app infrastructure and Connections) are ready, create a DevOps pipeline to deploy these resources to Azure and to update app settings.

Define a DevOps pipeline that include the steps below:

  • Deploy the Logic App infrastructure template
  • Retrieve ARM output parameters
  • Deploy Connections template
  • Retrieve ARM output parameters
  • Add connection Runtime URL in the app settings configuration

Example: LogicAppStandard/iac-pipeline.yml at master · ShreeDivyaMV/LogicAppStandard (github.com)

 

Step 4 – Setup the CI pipeline

 

In this step, we would create a ZIP package of the workflows folder, based on the source code repository. For example, you can push your VSCode project to source control and trigger a run of this pipeline whenever there is any commit to the project.

Please note that the changes below are required in the connections.json file.

Update the Azure connections section with the app setting property of connection runtime URL and parameterize the authentication field. Create a parameter file for storing the authentication details.

In this example, we are using built-in and function app connections as well, so we update the connection metadata for these connections as well with app settings. Make note of these App setting fields, as they are required later in the CD pipeline.

Please refer to the code snippet below for more details.

 

{
    "functionConnections": {
        "azureFunctionOperation": {
            "authentication": {
                "name": "Code",
                "type": "QueryString",
                "val-ue": "@appsetting('azureFunctionOperation_functionAppKey')"
            },
            "displayName": "FunctionApiConnection",
            "function": {
                "id": "@appsetting('azureFunctionOperation_functionResourceURI')"
            },
            "trig-gerUrl": "@appsetting('azureFunctionOperation_functionTriggerURI')"
        }
    },
    "managedApiConnections": {
        "azureblob": {
            "api": {
                "id": "/subscriptions/@appsetting('WORKFLOWS_SUBSCRIPTION_ID')/providers/Microsoft.Web/locations/@appsetting('WORKFLOWS_LOCATION_NAME')/managedApis/azureblob"
            },
            "authentication": "@parameters('blob_auth')",
            "connection": {
                "id": "/subscriptions/@appsetting('WORKFLOWS_SUBSCRIPTION_ID')/resourceGroups/@appsetting('WORKFLOWS_RESOURCE_GROUP_NAME')/providers/Microsoft.Web/connections/azureblob"
            },
            "connec-tionRuntimeUrl": "@appsetting('BLOB_CONNECTION_RUNTIMEURL')"
        }
    },
    "serviceProviderConnections": {
        "serviceBus": {
            "displayName": "ServiceBus-Builtin",
            "parameterValues": {
                "connection-String": "@appsetting('serviceBus_connectionString')"
            },
            "serviceProvider": {
                "id": "/serviceProviders/serviceBus"
            }
        }
    }
}

 

Follow the steps below:

  • Add the project folder to your repository.
  • Create a DevOps pipeline to zip the project folder and publish the artefacts

Example: LogicAppStandard/ci-pipeline.yml at master · ShreeDivyaMV/LogicAppStandard (github.com)

 

Step 5 – Setup the CD pipeline

 

In this step, we would create a pipeline to deploy the zip package created in the previous step. During this step we update the app settings for all the app settings parameters used in the Connections.json file, so they can be found during runtime.

Create a DevOps pipeline to include the steps below

  • Add the app setting configuration for built-in and function app connections.
  • Deploy the workflows from the package created in the above CI pipeline.

Example: LogicAppStandard/cd-pipeline.yml at master · ShreeDivyaMV/LogicAppStandard (github.com)

 

Demo

 

In this example, I am using two workflows with an azure connection, a service provider connection and a function connection.

Create an Azure DevOps project and create a service connection for your Azure subscription.

Connect to Microsoft Azure - Azure Pipelines | Microsoft Docs

 

 

Create three azure pipelines (IAC pipeline, CI pipeline and CD pipeline) using the yaml files created in the above steps.

 

 

 

Update the service connection name, resource group and LA name in the variables.yaml and the TODO sections in the pipeline yaml files.

Run the pipelines one by one, verify that the logic app, connections, and workflows are deployed.

 

 

References:

 

DevOps deployment for single-tenant Azure Logic Apps - Azure Logic Apps | Microsoft Docs

Set up DevOps for Standard logic apps - Azure Logic Apps | Microsoft Docs

Root Repository: logicapps/azure-devops-sample at master · Azure/logicapps (github.com)

GitHub Repo used in the example: LogicAppStandard/azure-devops-sample at master · ShreeDivyaMV/LogicAppStandard (github.com)

 

 

 

 

 

 

 

Updated Jun 23, 2022
Version 1.0

10 Comments

  • arijitroy008's avatar
    arijitroy008
    Copper Contributor

    Shree_Divya_M_V 

    Hi,

    I am trying to deploy a standard logic app but after following the steps, the workflow code is visible from Kudu Console but it is not appearing in the Logic Apps Workflows. Could you please guide if I am missing something?

    Thanks!

  • How do we set up the release pipelines for different environments? For e.g Test and Prod.

  • SumitGaur680's avatar
    SumitGaur680
    Copper Contributor

    Hi Shree_Divya_M_V , 

     

    i was able to do it without using az-cli but instead of using an existing task called File Transformation in the release pipeline. Link to the task: https://learn.microsoft.com/en-gb/azure/devops/pipelines/tasks/reference/file-transform-v2?view=azure-pipelines

    the task can override both XML and JSON file and that too in a zip package. 

    we are maintaining variable groups for different environment where we store our parameter values for that environment and link the variable group to the associated stage in the release pipeline, so DEV variable group link with DEV Stage. how it works is basically if you have parameter in your file like below: 

     

    "BASE_URL": {
        "type": "String",
        "value": "\\server1\orders\dev\purchaseorder"
      }
     
    you can define an entry in the variable group like BASE_URL.value\\server1\orders\qa\purchaseorder for your qa environment for example and task will override the dev environment value with QA environment from the variable group, this task need to used before the function deployment task. 
    enielezi  you can have a look at it as well, you would then not need to maintain different parameter file your for different environment. 
     
     

     

     

  • SumitGaur680 , sorry for the delay in responding to the comment. I hope you have found the answer, otherwise please find below the steps.  I have included these steps in the other article https://techcommunity.microsoft.com/t5/azure-integration-services-blog/a-walkthrough-of-parameterization-of-different-connection-types/ba-p/3758413

     

    You can update the parameter file using below CLI command. This can be added as a DevOps task too.

    az functionapp deploy --resource-group <Resource group> --name <logic app name> --src-path <Parameter file path> --type static --target-path parameters.json
    Example:
    az functionapp deploy --resource-group TriageDemo --name shmvlastandarddemo1 --src-path /home/shree/parameters_azure.json --type static --target-path parameters.json

  • enielezi's avatar
    enielezi
    Copper Contributor

    Good point SumitGaur680 ! We have managed to deploy workflows as a .zip and are not including parameters.json but creating them manually in each environment, which is not ideal! Would be good to see if there is a way to have different parameters.json file for each environment or replace its values using a task. 

  • SumitGaur680's avatar
    SumitGaur680
    Copper Contributor

    the article is quite good, though i have query how you're gonna manage parameters.json file for the workflow for the different environment. the workflow parameters could be different for each environment and hence need to be updated to the environment accordingly. 

    i have not seen anything on the CI or CD pipeline which does a override of the parameters for the specific environment.

  • enielezi's avatar
    enielezi
    Copper Contributor

    Very difficult to follow using gifs! Logic App standards are so important  part of our infrastructure but so difficult to deploy (unlike Data Factory which have dedicated Devops tasks).

    Can you please create a video for this deployment? 

  • ershadnozari's avatar
    ershadnozari
    Copper Contributor

    Is it possible to produce a video/tutorial on how to do this step-by-step on Azure DevOps? I don't fint the docs very intuitive. Cheers