gpt4 book ai didi

azure - 发布到 Azure 后无法将函数参数绑定(bind)到类型 TraceWriter

转载 作者:行者123 更新时间:2023-12-02 07:48:35 24 4
gpt4 key购买 nike

我正在遵循指南 https://mikhail.io/2017/12/precompiled-azure-functions-in-fsharp/ :

  1. 已创建 dotnet f# 项目:dotnet new classlib --language F# --name HelloFunctions
  2. 添加了对函数的引用:dotnet add package Microsoft.NET.Sdk.Functions
  3. 添加了新函数(如下面的 Library.fs 文件中所述),添加了配置文件等。
  4. 编译函数
  5. 它在本地成功启动 dotnet build && dotnet publish && cd bin/Debug/netstandard2.0/publish && func start .
  6. 将其发布到 Azure:func azure functionapp publish <name>
  7. Azure看到功能了,没问题。
  8. 当我通过单击树中的名称导航到函数时,会弹出错误消息:

    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.).
  9. 该功能似乎不起作用。可能是因为上面的错误。

库.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

最佳答案

听起来很像程序集版本冲突(运行时运行一个版本的 Microsoft.Azure.WebJobs.Host.dll,而您的应用引用另一个版本)。

我的猜测是,您使用运行时版本 2.0 编译了本地应用程序,而 Azure Function App 配置为 1.0(默认)。请检查。

关于azure - 发布到 Azure 后无法将函数参数绑定(bind)到类型 TraceWriter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47764945/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com