When it comes to developing Logic Apps, everyone has a preference. Some people like to develop in the portal, while others like to start development directly from Visual Studio. I am in the first group mainly because a lot of my logic apps involves integration with the Dynamics 365 CRM connector, which doesn’t play well with the Logic Apps editor after I apply the required parameterization (which reminds me that I have to blog about that – will write something about it soon). I also like the simplicity of just opening the browser and be able to develop, debug all in one go.
The Logic Apps product team has put a lot of effort in making this experience simple, always improving the editor. So I decided to share a couple of the tricks (or hacks, if you choose) I use when developing/testing Logic Apps.
Using clone as a check-out / commit tool
The Clone logic app is quite a nice feature. It allow you to copy the whole definition of a logic app to either a new or existing logic app.
I use this feature as a way to “check out” existing logic apps to either fix bugs, implement requirement changes or refactor it.
Cloning is quite a simple process. On an existing logic app, you just need to click the Clone button
Then you just need to provide a couple of details:
From those, two are quite important.
- Name – the name of the cloned logic app will decide if a brand new workflow will be created, or if the logic app will overwrite an existing logic app – this is important for the whole check-out/commit idea. If you are overwriting a logic app, a warning will appear, so you don’t overwrite anything by mistake.
- Logic App Status – this decides if the status the logic app being deployed (either a new one or an existing) will be enabled or disabled. This is important, because for some types of triggers, having the cloned logic app enable means that you will either have competing consumers or duplicated subscriptions (more about that in a minute).
“Checking out” Logic Apps
I use this functionality to create a developement copy of a logic app. When I need to make changes in a workflow in my environment, I:
- Clone it to a DEV-<LogicAppName> in the same resource group.
- Work on the code of the DEV version
- Once I am happy that the code is ready to be promoted back to the main logic app, I clone the DEV-<LogicAppName> back to the <LogicAppName> workflow.
What that gives me?
- The ability to continue using the existing Logic App while I am amending the code, changing the logic, etc.
- Ability to test against both under development and existing logic apps by enabling/disabling one of the versions.
- A cleaner version history on the main LogicApp, as it only keep release candidate versions in the history.
There is one main gotcha on this approach, specially for Logic Apps that uses polling based triggers. You must remember to disable one of the copies – ideally the “checked out” version. I had cases where things mysteriously disappeared from queues or were executed twice, until I realized that I had two logic apps consuming the same resources.
Versioning as a Rollback mechanism
I’ve mentioned that one of the advantages on using the clone for “checkout/commit” is that I keep the main logic app version cleaner. This guarantee that rolling back is as easy as point to one of the previous versions, so in this case, the less the better.
I also use versioning a lot to play “what if” scenarios. For example, when answering forum questions, I like to prototype my answer as a logic app. Then test various potential solutions. Having the ability to test a solution then roll back to the previous stable one if things go pear-shaped is quite useful.
Versioning is also quite simple to use. You will find your versions in the Logic App blade.
Within the versions blade, you can see a list of versions with the dates it was saved. Each time you save a logic app, you create a new version.
Clicking in one of the versions and you will see the workflow definition. You can see the designer or the code view, and you can also make any version the published (latest) version by clicking the promote button.
Unfortunately the versions feature don’t allow you to add a comment or a description in the version – seems like the only thing missing. Would be great to be able to search for annotated information
So in summary, you can have a bit more control on your logic apps source code within your environment, by leveraging from clone and versions feature.
See you next time, Wagner.