NAV Extensions: using custom DLLs from Azure Functions

I need to give a response to many of you that have asked me many questions regarding the “Microsoft Dynamics NAV Extensions and add-ins pain” post.

In this post (and in many following discussions) I’ve said you that the actual official Microsoft’s recommended way to use .NET in AL for Microsoft Dynamics NAV/Dynamics 365 (SaaS environment) is to use Azure Functions. The natural question that I’ve received was: “ok, but if we go with the Azure Function approach, should I rewrite all my .NET code in the cloud environment? What about all my custom DLLs that actually I’m using on-premise that I’ve developed with Visual Studio and C# during the past years?“.

The answer is: you can use your .NET DLLs “as-is” also on Azure Function! You don’t need to rewrite code in the cloud, but you can simply deploy your DLLs and use them from an Azure Function.

How to do that?

Let’s start with creating a sample Azure Function via the Azure Portal (the scope of this post is only to show how you can use a DLL, so the function will not be 100% complete) by clicking on New, then Function App and then Create:


In the Function App blade, set the App name (it must be unique!) and other parameters like Resource Group, Location, Hosting Plan and so on. Then click Create;


After few minutes the Function App will be deployed. Now select your Function App, then select Functions and then New Function:


Here I’ve created a simple HTTP Trigger with C#:


Now in the HTTP Trigger blade, select the name of your trigger and click Create:


The trigger is created and you have a window where you can start writing your C# code.

What I want to do now is to add a reference to a custom DLL (I want to use it on my Azure Function) and this is the tricky part: to do this, you need access to the SCM / KUDU console. Copy the url of your Azure Function in a new browser window and add the word scm between the app name and the url part. The KUDU console is reachable at the url <webappname>


Loading this url on a browser window will present you the KUDU page and from here you can launch the KUDU CMD console:


Now navigate the web app folders to the method you have previously created (exactly like in a Command Prompt window) and within it, create a BIN folder:


In this BIN folder, you can paste your custom DLLs that you want to use in your Azure Function (drag & drop from your PC to the browser window):


For referencing these DLLs in your Azure Function code, you need to go to your Azure Function definition (in my case the HTTP Trigger I’ve defined) and as the first line of your function’s code you need to add the reference to your previously deployed assembly using the #r identifier followed by the path of your DLL (path that you can read from the KUDU console):


As you can see in the previous picture, after adding the reference to the assembly, you can use it on your Azure Function code. The worst part here is that at the moment there’s no intellisense, so you can’t see the methods exposed by your DLL and you need to know the proper way to call the methods.

Hoping this will anwser many questions related to the DLL-panic topic… 😀


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.