【发布时间】:2017-12-12 03:32:48
【问题描述】:
我正在关注https://mikhail.io/2017/12/precompiled-azure-functions-in-fsharp/的指南:
- 已创建 dotnet f# 项目:
dotnet new classlib --language F# --name HelloFunctions - 添加了对函数的引用:
dotnet add package Microsoft.NET.Sdk.Functions - 添加了如下文件 Library.fs 中所述的新功能,添加了配置文件等。
- 编译函数
- 用
dotnet build && dotnet publish && cd bin/Debug/netstandard2.0/publish && func start在本地成功启动。 - 将其发布到 Azure:
func azure functionapp publish <name> - Azure看功能,没问题。
-
当我通过单击树中的名称导航到功能时,会弹出错误消息:
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.). - 该功能似乎不起作用。可能是因为上面的错误。
库.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
【问题讨论】:
-
库版本不兼容:您的程序集是针对与函数框架使用的不同的 .NET 版本编译的。
标签: azure f# azure-functions