Logic Apps and the purpose of Azure Functions
I have been looking at Azure Logic Apps since last year, but I couldn’t find a purpose for it, except retweeting a tweet. I couldn’t find a real world scenario for it. It was just too limited. There are connectors, but what should I do with the message? Maybe a BizTalk mapping or fire a business rule? And you need BizTalk Services for that. I don’t know about BizTalk Services, but it’s not cheap. I can tell you that.
Of course API apps were the way to go if you needed some intelligence in your Logic App. But you don’t “just deploy” an API app for some helper functionality. Especially if you are working in Visual Studio 2012 for your BizTalk Services and need the latest version of Visual Studio (2015) to get that API app up in the cloud. That’s insane. Even after the update last February, it was still hard to get things done. As committed as the team was. It was missing some essentials.
But behold! Azure Functions have arrived and things suddenly become a lot easier. You can actually get things done now. It simplifies the entire process. Azure Functions are small pieces of code that react to an event. They are triggered by external events, be it HTTP or a schedule. Whether you want to manipulate a the data you received or want to call into a database or storage account for additional functionality. It is all there and can even be used within your Logic Apps.
Calling Azure Functions from a Logic App
It’s now very easy to use Function Apps from within your logic app, which makes it all even more interesting. This way we can really speed up development of Logic Apps.
If you go into your logic app, it’s very easy to select your Azure Functions and use them.
After you select your container, you can either choose for a Function App you previously created in the container or create a new one. Right from the designer. This way you can bundle your helper functions for instance. Although this leaves you with – and if you are a BizTalker, it’s the story of our lives – a non-resizable tiny window with 3 lines of code.
Ok. I was mistaken. It’s actually 4.5 lines of code in there 🙂 As I understood, the team is also pretty busy giving the ability to edit existing functions from the editor. We’ll have to see how that works out. But it’s a neat feature indeed. It doesn’t give you the ability to use C# or any other language yet from the designer, so for now that leaves us getting the Javascript skills up to par.
After creating the Function App you will actually be able to use the payload (body) returned by the function (duh!). So, in the simplest of scenarios, you can output the body returned by the function app directly to the caller.
In the example below, I simply output concatenate “Hello ” with the input payload (myname). Which will result in “Hello Rob” in my case.
So, as you can see, it’s now a lot easier to get things done. You can actually do some math in your Logic App. And with math, I mean math. Like adding 1 plus 1, which was really merely impossible to do in a timely fashion before Azure Functions. I am pretty excited about it and will dive deeper in Logic Apps and Functions in my upcoming blog posts. So stay tuned!