Deploy LogicApps using linked templates

Deploying LogicApps with VSTS is easy. You can create a new project using the steps defined in this post and you are all set with deployment settings in place.

But, when you add more and more LogicApps your JSON file will grow and you might be better off putting each LogicApp within its own JSON. Not to speak of the parameters running wild within your files…
This post will explain how to set this up, and what is needed in your VSTS builds to enable the deployment of all the linked apps.

Multiple LogicApps

When you add a LogicApp to your existing project, you can expect a settings screen like below:

1AddLogicApp

The result is a new set of params and a new resource:

2TwoApps

Splitting up the LogicApps

To split up the files, several steps need to be taken.

  1. Move the LogicApps from the main JSON to separate files
  2. Update the main JSON file to point to the new separated files, and add parametes to work with artifacts/SAS during deployment
  3. Update the parameters file to set names and other settings

1. Move the LogicApps

The first step of separating the files is to create a folder (although not necessary, highly recommended because of readability) within your solution, and move the separate LogicApps into those folders.

3Folders

2. Update LogicApp.json and add parameters

To link these new JSON files, the LogicApp.json needs to be updated, like in the following gist. Three new parameters are added to the JSON. The first two are used to link in VSTS to the blob storage that will hold these templates.

https://gist.github.com/prombouts/f541e53fecc95a95d0f8940710cd15b7.js

3. Update LogicApp.parameters.json

Finally we have to edit the parameters file. The next gist show how the default setup is, when creating LogicApps within one single JSON:

https://gist.github.com/prombouts/105351d5bbc5a364c0cfc2b1d9184160.js

The next example show how to create a new configurationparameter object to hold the settings for the separate files. We will refer to these in the LogicApps within the folder.
https://gist.github.com/prombouts/eab9aa4963a09df052718cb3dd62716a.js

Setup VSTS build

To leverage these templates, some additional steps need to be taken in VSTS. For example the artifacts and SAS tokens should be passed in as parameters.

Build step

In the build step, the templates should be copied to blob storage. After all, the linked templates only work with full URLs so we must place these in storage. Note the output parameters to be used in the next steps when validating the template:

3Artifacts

Make sure you publish the artifacts to a folder, so you can pick these up in the release step!

Release step

Finally the release should be setup. In the first step the files are copied to blob storage, and the output parameters are used to capture the sas tokens.

4CopyBlob

Secondly the actual deploy uses the parameters from the previous step and deploys the actual apps to Azure.

5Deploy

Conclusion

Setting up the pipeline with linked templates is not difficult, but will take more time to setup properly. When everything is in place, adding more templates is very easy and the separation of the various apps in separate json files will increase maintainability and readability. It will also help you share your templates with your peers.

Feel free to ask me anything on this subject; drop me an email or contact me on Twitter.