I have a quite big project with Azure Function v2 written in F#. I create a library in C# where in the constructor I can pass a ILogger log
. If only I add this library in the Azure Function project, every function returns an error.
Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type ILogger. Make sure the parameter Type is supported by the binding
In F# I tried to add
[<FunctionName("organization")>]
let public organization
( [<HttpTrigger(AuthorizationLevel.Function, "post", Route = "organisations/{organisationId}")>]
request : HttpRequestMessage,
organisationId : string,
executionContext : ExecutionContext,
log : ILogger) =
let PaymentGateway = PaymentGateway(Environment.GetEnvironmentVariable "Api_Secret_Key", log)
...
I saw some posts for example on GitHub or another post where other people have the same issue. Apparently, the solution is to update the Azure Function from v2 to v3 but I can't do that in my case right now.
Is there any solution?
Update
The .fsproj
is
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<Content Include="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.6.2" />
</ItemGroup>
</Project>