如何将 Azure 函数的入口点放入 .NET DLL 中?
How to put the entry point of an Azure Function inside a .NET DLL?
Azure Functions samples 说明了如何将进程入口点放在 C# 脚本文件中 .csx
。但是,如何使用常规 C# 库 (DLL) 实现该行为呢?我可以让 Kudu 像为 Webapp 一样先编译库吗?
乔安妮,
目前不支持此功能,但您可以按照所述here发布带有函数的程序集,并让函数入口点调用程序集中的适当方法:
#r "MyAssembly.dll"
public static void Run(/*...args...*/)
{
MyAssembly.MyMethod(/*..args...*/);
}
在撰写此问题时,它不受支持,但现在支持!
https://github.com/Azure/azure-webjobs-sdk-script/wiki/Precompiled-functions
维基摘录:
{
"scriptFile": "PreCompiledFunctionSample.dll",
"entryPoint": "PreCompiledFunctionSample.MyFunction.Run",
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in"
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
],
"disabled": false
}
Azure Functions samples 说明了如何将进程入口点放在 C# 脚本文件中 .csx
。但是,如何使用常规 C# 库 (DLL) 实现该行为呢?我可以让 Kudu 像为 Webapp 一样先编译库吗?
乔安妮,
目前不支持此功能,但您可以按照所述here发布带有函数的程序集,并让函数入口点调用程序集中的适当方法:
#r "MyAssembly.dll"
public static void Run(/*...args...*/)
{
MyAssembly.MyMethod(/*..args...*/);
}
在撰写此问题时,它不受支持,但现在支持!
https://github.com/Azure/azure-webjobs-sdk-script/wiki/Precompiled-functions
维基摘录:
{
"scriptFile": "PreCompiledFunctionSample.dll",
"entryPoint": "PreCompiledFunctionSample.MyFunction.Run",
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in"
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
],
"disabled": false
}