1

The Azure Functions samples illustrate how to put the process entry point within a C# script file .csx. However, how can I achieve the behavior with a regular C# library (DLL) instead? Can I get Kudu to compile the library first much like it is done for Webapp?

Joannes Vermorel
  • 8,976
  • 12
  • 64
  • 104
  • 2
    Possible duplicate of [Execute pre-compiled .NET code as Azure Function](http://stackoverflow.com/questions/36436917/execute-pre-compiled-net-code-as-azure-function) – Mikhail Shilkov Apr 12 '16 at 17:39

2 Answers2

4

Joannes,

This is not currently supported, but you can publish your assembly with your function as described here and just have your function entry point call the appropriate method in your assembly:

#r "MyAssembly.dll"

public static void Run(/*...args...*/)
{
    MyAssembly.MyMethod(/*..args...*/);
}
Fabio Cavalcante
  • 12,328
  • 3
  • 35
  • 43
2

As of the writing of this question, it was not supported, but now it is!

https://github.com/Azure/azure-webjobs-sdk-script/wiki/Precompiled-functions

Excerpt from wiki:

{
"scriptFile": "PreCompiledFunctionSample.dll",
"entryPoint": "PreCompiledFunctionSample.MyFunction.Run",
"bindings": [
    {
        "authLevel": "function",
        "name": "req",
        "type": "httpTrigger",
        "direction": "in"
    },
    {
        "name": "$return",
        "type": "http",
        "direction": "out"
    }
],
"disabled": false
}
Brian Ball
  • 12,268
  • 3
  • 40
  • 51
  • Do you put PrecompiledFunctionSample.Dll under d:/site/wwwroot/MyFunction/bin? I can't get it too work, except on the local emulator. The function embedded in the Dll and declared as entryPoint id not found by Kudu accordinng to logs, even if it's public, static, in a public class – Emmanuel DURIN Feb 10 '17 at 14:43
  • To be honest, I haven't done it myself yet (I keep meaning to get around to it). I would try both. I would also make sure you are running the latest version of Azure Functions, the version you are using does not get automatically upgraded, you have to do that yourself (you can do it via the Azure portal). – Brian Ball Feb 10 '17 at 16:26