Handling Calling another Logic App in the ARM Template
  • Updated on 21 Jan 2020
  • 2 minutes to read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

Handling Calling another Logic App in the ARM Template

  • Print
  • Comments
  • Share
  • Dark
    Light

When you are referencing another logic app (or other resource) in your Logic App, one of the problems is you add it to the designer then under the hood you get some json which specifies an direct path to the logic app (or resource) and when you come to deploy these to other environments you will be pointing to the wrong Logic App.

These settings need to be parameterised. There are a couple of different ways to do this and one I quite like I will describe below. The reason I like this approach is its easy to implement but also it makes the json under the hood easy to read too.

To start with lets imagine I have added my Logic App and have some json under the hood something like below:

"Call_Exception_LogicApp": {
                          "type": "Workflow",
                          "inputs": {
                            "host": {
                              "triggerName": "manual",
                              "workflow": {
                                "id": "/subscriptions/[My ResourceGroup ID]/resourceGroups/[My ResourceGroup Name]/providers/Microsoft.Logic/workflows/LogicApp2"
                              }
                            },
                            "body": {
                              "Application Name": "@{workflow()['name']}",                              
                            }
                          },
                          "runAfter": {}
                        }

I have removed the guid and name for the resource group above but you can see the point. The id property has the hard coded path which needs to be parameterised. I like to avoid as much as possible hand editing the json files in Logic Apps but in real world scenarios this is something you do need to do.

To make it easy I add a parameter in the template like the below. I prefix this with "arm_" so that I know its an ARM parameter.

"arm_myResourceGroupPath": {
      "type": "string",
      "defaultValue": "/subscriptions/[Add Guid Here]/resourceGroups/[Resource Group Name Here]"
    },

This parameter then takes the default for my resource group path.

I then update my Logic App call like the below to include a function using "concat" to add the resource group path before a string which is the rest of my path to the Logic App I want to call.

"LogicApp2": {
              "type": "Workflow",
              "inputs": {
                "host": {
                  "triggerName": "manual",
                  "workflow": {
                    "id": "[concat(parameters('arm_myResourceGroupPath'), '/providers/Microsoft.Logic/workflows/LogicApp2')]"
                  }
                },
                "body": "@variables('sapMessage')"
              }

Incase its not obvious above I have highlighted the function below:

"[concat(parameters('arm_myResourceGroupPath'), '/providers/Microsoft.Logic/workflows/LogicApp2')]

This means that when I deploy my Logic App the ARM template will inject the value of the parameter into the id path and point my Action to the right Logic App.

When I then come to Azure DevOps and want to deploy to other environments I simply add a build/release pipeline variable called arm_myResourceGroupPath with the appropriate value for each environment.

I mentioned that there are other ways to do this, but the benefits I like about this are:

  1. Its dead simple
  2. I dont need a much more complex concat function usage which for other resources can be more complicated
  3. It is easy to use with the DevOps pipeline
  4. I can use it with other resource types if needed

Id be interested to hear if anyone else has a good approach for doing this. I would really like Microsoft to automatically parameterize this kind of thing when it goes into the Logic App in Visual Studio. Doing this automatically would significantly reduce the amount of json editing Id need to do!

Was this article helpful?