简体   繁体   English

如何将Azure函数的入口点放在.NET DLL中?

[英]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 . Azure Functions示例说明了如何将进程入口点放入C#脚本文件.csx However, how can I achieve the behavior with a regular C# library (DLL) instead? 但是,如何使用常规C#库(DLL)来实现此行为? Can I get Kudu to compile the library first much like it is done for Webapp? 我可以让Kudu像在Webapp中一样首先编译库吗?

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

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 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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM