Published 20 January 2021

Logic AppsAzureAzure DevOpsApp ConfigurationYaml

Overview

The idea behind this post is to provide some useful tips and considerations for deploying Logic Apps

Parameters

One thing I find quite useful is to introduce parameters for any content that needs to be updated dynamically per environment, this means that if you are changing anything in the UI you can copy the actions block without worrying about overrwriting in parameter replacement.

Example

In the following template snippet, you can see that within the actions block the Logic Apps parameters are being used rather than directly using the ARM template parameters, this means we can copy the actions block directly from the ARM template export within Azure and not worry about having to change back the parameters block.

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "microsoftTeamChannelId": {
      "type": "string"
    },
    "microsoftTeamId": {
      "type": "string"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Logic/workflows",
      ...
      "properties": {
        "definition": {
          "parameters": {
            "teamChannelId": {
              "defaultValue": "",
              "type": "String"
            },
            "teamId": {
              "defaultValue": "",
              "type": "String"
            },
          },
          ...
          "actions": {
            "Business_Logic": {
              "actions": {
                "Post_to_Teams_Channel": {
                  "runAfter": {},
                  "type": "ApiConnectionWebhook",
                  "inputs": {
                    "body": {
                      "body": {
                        "messageBody": "Test Teams Message",
                        "recipient": {
                          "channelId": "@{parameters('teamChannelId')}"
                        }
                      },
                      "notificationUrl": "@{listCallbackUrl()}"
                    },
                    "host": {
                      "connection": {
                        "name": "@parameters('$connections')['teams']['connectionId']"
                      }
                    },
                    "path": "/flowbot/actions/flowcontinuation/recipienttypes/channel/$subscriptions",
                    "queries": {
                      "groupId": "@{parameters('teamId')}"
                    }
                  },
                  "runtimeConfiguration": {
                    "staticResult": {}
                  }
                }
              },
              "runAfter": {},
              "type": "Scope"
            }
          },
          "outputs": {}
        },
        "parameters": {
          ...
          "teamId": {
            "value": "[parameters('microsoftTeamId')]"
          },
          "teamChannelId": {
            "value": "[parameters('microsoftTeamChannelId')]"
          }
        }
      }
    }
  ]
}