Azure Logic Apps have to be one of the coolest features that Microsoft has put out on their cloud service portal. There are a bunch of reasons why:
- If you want to get around CORS, you can call your Logic App which could call an external API.
- No spinning up servers to run it. You just make one and it takes care of all of the resources.
- There are a ton of different built-in connectors (screenshot below) you can use to make something work with something else (Kind of like If This Than That (IFTT) on steroids).
Why did I do this?
In my support role, I need to access BizStream’s support desk in different ways, and my goal is to automate that as much as possible. At BizStream we use Freshdesk
for our support needs. I have created a C# web application to handle some of the integration, but I was running into CORS request issues (because my domain is different). Now I understand the necessity of CORS and why it was created, but that doesn't stop me from hating it with a burning and fiery passion of a thousand suns. In order for my web-app to access anything, I need to make my own web service, spin it up, allocate resources for it, and maintain them. I didn't want to do any of that, here is where Azure Logic Apps
came to my rescue.
Creating a Logic App
To follow along with the rest of the post, you will need to have your own Azure account, but if you don’t, create a free trial account and Microsoft will give you $200 of service credits to use. As long as you are using the Azure Logic App features and nothing else, that $200 can go a long way. You can find out what the Azure Logic Apps cost
pretty easily, it is a transparent pricing model. Honestly, it is inexpensive per action. Try out the Azure pricing calculator
Once you have an account for Azure, login to the Azure portal. You need to create something for the Logic App to run in, which is where Resource Groups
come in. If you are running a business with a bunch of people needing access to different Logic Apps, Resource Groups help separate out resources for those different people or apps. But if you are just trying this as a single developer don’t worry about Resource Groups for now.
Once you have your Resource Group made, you can create your Logic App to live there. You can create them simply by going to "Create a resource
" and search for Resource Group and/or Logic App. They have a bunch of samples that you can use if something already exists that you want to start from, but I've found their designer mode is intuitive enough so you can make an app pretty easily.
After you create your Logic App, you will be redirected to the overview panel. The overview panel gives you just about all the information you want from your app. A few things you can do on this screen I've found very helpful are:
- The Disable Feature - If you have a runaway loop, just click it, and everything stops
- Runs Last 24 Hours - very helpful if you are trying to figure out pricing
- Runs History - If you click on one of these, you can get all of the debugging information on the app as though you had run it yourself from the Design screen on any of the apps recent runs
Now for the fun stuff
Every Logic App has to start with a Trigger which is something that starts the app. It can be a recurring schedule which makes the app run every so often or an HTTP request that's called from an app somewhere. Or it can be something built in. In my case, it was the Freshdesk connector that I was using.
From here on out, you can use steps for logic connectors to do what you want. When debugging there are a couple of things that I've found helpful to troubleshoot.
- Use the Slack connector. When I'm not sure what an action is returning, sometimes I'll shoot the output out to my slack username. if you don't use Slack, you can use the Email connector to send yourself an email of the problem.
- Use the Configure run after an action to log any kind of failure. This way you can push an error through the workflow to get to the step you want.
- Run the app and see what the output of each action is. As an alternative to actually running the app, you can go to the overview screen and click on one of the last runs to view the results yourself.
Here are a few tips/tricks that I learned along the way with some caveats to Azure's designer mode.
- Beware of the Until control. If one step fails, I've found that it will continue to run until it hits its limit. As a trick to avoid this, you can set a limit on the Until loop itself.
- There is an issue if you are copying and pasting text into some of their fields. Especially if you are using JSON text. Just be aware that you may have to reload the page if it doesn’t paste in ok.
- When you use the http control and you are calling a child logic app, make sure you add the header "content-type: application/json", or you will get parsing problems on the child app
- There isn't a good way to disable a single action, so as a workaround, I created a conditional control, and say if 1=1, then do the controls that I made, or do the control that I disabled.
- The JSON parse control is very useful in the sense that it auto-generates a JSON object from a sample object you can pass it. However, if you have child objects or arrays of objects, it can get tricky. As a workaround to this, I've found that you can select them using the format used in the screenshot.
This is a sample for how to select the webhook of the third SLA account on the triggerBody()
(which is the JSON that was passed into my Logic App). Below is a sample of the JSON that I am grabbing from
At the end of the day my Logic App looks like this:
And the integration between Freshdesk and Slack for BizStream results with:
Overall Azure Logic Apps is very impressive and has some cool features. It saved me time by not having to build my own application with a bunch of SDKs installed or custom API calls. I'm hoping to implement more and more of them since they don't require a platform to spin them up on.
Side note, if you need a support desk type of service, we highly recommend Freshdesk. It rocks.