簡體   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