1
votes

I'm following the guide https://mikhail.io/2017/12/precompiled-azure-functions-in-fsharp/:

  1. Created dotnet f# project: dotnet new classlib --language F# --name HelloFunctions
  2. Added reference to functions: dotnet add package Microsoft.NET.Sdk.Functions
  3. Added a new function as noted in file Library.fs below, added configuration files, etc.
  4. Compiled the function
  5. It successfully starts locally with dotnet build && dotnet publish && cd bin/Debug/netstandard2.0/publish && func start.
  6. Publish it to Azure: func azure functionapp publish <name>
  7. Azure sees the function, it is ok.
  8. When I navigate to function by clicking its name in the tree the error popups:

    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. The function does not seem to be working. Perhaps because of the error above.

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
1
Incompatible library versions: your assembly is compiled against a version of .NET that is different from what the function framework is using. - Fyodor Soikin

1 Answers

4
votes

Sounds very much like assembly version conflict (runtime running one version of Microsoft.Azure.WebJobs.Host.dll, while your app referenced the other).

My guess would be that you compiled your local app with version 2.0 of the runtime, while Azure Function App is configured to 1.0 (default). Please check.