Joannes Vermorel
Joannes Vermorel

Reputation: 9245

How to put the entry point of an Azure Function inside a .NET DLL?

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?

Upvotes: 1

Views: 2092

Answers (2)

Brian Ball
Brian Ball

Reputation: 12596

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
}

Upvotes: 2

Fabio Cavalcante
Fabio Cavalcante

Reputation: 12538

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...*/);
}

Upvotes: 4

Related Questions