Navigate Into Success: Invoking Azure Functions from AL
One elegant way of replacing your .NET interoperability code with something else is by using Azure Functions. Sounds good in theory, but what does it take in practice? And what are Azure Functions, anyway?
Let me not take too much latitude, and let me just say that Azure Functions are a way of running simple pieces of code as a service that you can invoke like any other RESTful web services. And of course, they run in Azure. To learn more about them, follow this link: https://docs.microsoft.com/en-us/azu...tions-overview
Creating them is as simple, as invoking them, so let’s get started with an extremely simple demo that will illustrate how amazingly powerful they are, and why they are a perfect solution for replacing your .NET code with something better.
Then, I’ll create a simple function with anonymous access, just for sake of simplicity:
And then, I’ll put some code in my “meaningOf” function:
As simple as that.
Then, I’ll copy the URL of the function by clicking Get function URL > Copy.
Next step is to create some AL code to consume this function. For that, I start with > AL: Go! and then replace the content of the HelloWorld.al file with this:
As you can see, calling RESTful services with the new Http API, that’s now available at AL language level is amazingly simple:
Now, invoking these functions is easy and they seem to be fast, too. However, how fast exactly are they?
There is a simple rule – your function must be deployed close to your NAV instance for it to be as fast as possible. If you run your NAV and host your Azure Function app in the same data center, you can expect some decent performance. However, if you host your NAV in US, and your Azure Functions in Japan, then your performance will be sluggish at best.
What exactly is “decent performance” and what exactly is “sluggish” can be easily quantified. I have deployed my NAV in an Azure VM in West Europe, and then deployed three Azure Function apps in West Europe, North Europe, and Australia South-East. Then, I have invoked this function a hundred times and I got these figures (averages of three runs):
However, that’s 28 milliseconds when you are doing everything in the same datacenter. Once your function and your NAV instance are a bit farther away, the latency kicks in and everything is not so wonderful anymore. This means that to have fantastic responsiveness, you’ll have to maintain copies of your functions in multiple datacenters.
Here’s the hero:
A man can dream, right?
Words of wisdom for the end? Not much. Azure Functions are both simple and powerful way to replace your .NET interoperability stuff with something very similar. They don’t perform as fast as in-process .NET does, but depending on what exactly you do, you won’t feel it a tiniest bit. And with a little bit of imagination, you can do crazy things with them. Crazy things.
Read this post at its original location at http://vjeko.com/invoking-azure-functions-al/, or visit the original blog at http://vjeko.com. 5e33c5f6cb90c441bd1f23d5b9eeca34The post Invoking Azure Functions from AL appeared first on Vjeko.com.
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|Navigate Into Success: State of .NET Affairs||Blog bot||NAV: Blogs||1||07.06.2017 11:03|
|Navigate Into Success: From C/AL to executable: how NAV runs your C/AL code||Blog bot||NAV: Blogs||0||06.10.2016 13:11|
|wiki.dynamicsbook: Changes Made in Navision Attain 3.60||Blog bot||Dynamics CRM: Blogs||0||02.09.2008 13:23|
|Опции темы||Поиск в этой теме|