繁体   English   中英

Dll中的C#Azure功能在Azure中不起作用(但在模拟器中)

[英]C# Azure Function in Dll doesn't work in Azure (but in emulator)

因为我想在部署之前完全编译Azure功能 ,并且因为我想在部署之前获得重构 (自动重命名)的所有好处 ,所以我想摆脱Csx文件并使用Dll

我希望我的所有代码都在.Dll中 - 完全编译。

所以它在本地模拟器中工作正常,但我不能让它在Azure中工作

我总是在日志文件中得到相同的错误消息:

MailSenderFunction: Unable to determine the primary function script.
Try renaming your entry point script to 'run' (or 'index' in the case of     Node),
or alternatively you can specify the name of the entry point script explicitly by adding a 'scriptFile' property to your function metadata.

我没有看到我的功能出现在门户网站的功能应用程序中。

function.json

{
  "disabled": false,
  "scriptFile": "./bin/MailSenderFunctionLib.dll",
  "entryPoint": "MyCompany.MailSenderFunctionLib.MailSenderFunctionProcessor.RunCsxLess",
  "bindings": [
    {
      ...
    }
  ]
}

Dll代码

namespace MyCompany.MailSenderFunctionLib
{
  public class MailSenderFunctionProcessor
  {
    public static void RunCsxLess(Mail mail)
    {
      // ...
    }
}

dll位于函数的bin目录中,而不是App Function的bin目录中

任何想法 ?

这将在下一版本的运行时(> 1.0.10690)中得到完全支持。

您可以在此处找到有关该增强功能的更多信息

您在本地运行时观察到不同行为的原因是,此时CLI预览(不幸的是)在托管环境之前并使用新的运行时位。 我们正在改变这个过程,以确保这些版本与其他版本保持同步。

我必须将dll放在与function.json相同的目录中,并从scriptFile中删除目录前缀。 我无法让它在子目录中工作。

我能够让它在子目录中工作的解决方法是使用run.csx文件导入.dll并只执行该dll中的静态方法。 如:

#r "DLLs\MyFunction.dll"

using System;

public static void Run(string myEventHubMessage, TraceWriter log)
{
    MyFunction.Program.Run(myEventHubMessage, log);
}

(在这个例子中我使用的是eventHubTrigger)

暂无
暂无

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

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