我遵循指南https://mikhail.io/2017/12/precompiled-azure-functions-in-fsharp/:
dotnet new classlib --language F# --name HelloFunctions
dotnet add package Microsoft.NET.Sdk.Functions
dotnet build && dotnet publish && cd bin/Debug/netstandard2.0/publish && func start
在本地成功启动。func azure functionapp publish <name>
当我通过在树中单击其名称导航到函数时,弹出错误:
Function ($Hello) Error: Microsoft.Azure.WebJobs.Host:
Error indexing method 'Functions.Hello'. Microsoft.Azure.WebJobs.Host:
Cannot bind parameter 'log' to type TraceWriter. Make sure the parameter Type
is supported by the binding. If you're using binding extensions (e.g.
ServiceBus, Timers, etc.) make sure you've called the
registration method for the extension(s) in your startup code (e.g.
config.UseServiceBus(), config.UseTimers(), etc.).
Library.fs
namespace HelloFunctions
open System
open Microsoft.Azure.WebJobs
open Microsoft.Azure.WebJobs.Host
module Say =
let private daysUntil (d: DateTime) =
(d - DateTime.Now).TotalDays |> int
let hello (timer: TimerInfo, log: TraceWriter) =
let christmas = new DateTime(2017, 12, 25)
daysUntil christmas
|> sprintf "%d days until Christmas"
|> log.Info
答案 0 :(得分:4)
听起来非常像汇编版本冲突(运行时运行Microsoft.Azure.WebJobs.Host.dll
的一个版本,而您的应用引用另一个版本)。
我的猜测是您使用运行时版本2.0编译本地应用程序,而Azure功能应用程序配置为1.0(默认值)。请检查。