The last Azure function registration parameter (ILogger or TraceWriter) is not accepted

After updating my own project from an earlier (several months ago) version of Azure Functions to the current one, I get the following error when starting from VS.

GetLoginUrl: Microsoft.Azure.WebJobs.Host: the error indexing method is 'Login.GetLoginUrl'. Microsoft.Azure.WebJobs.Host: Unable to bind the log parameter to ILogger type. Verify that the parameter type is supported by binding. If you use binding extensions (e.g. ServiceBus, Timers, etc.), make sure you call the registration method for the extensions (s) in your startup code (e.g. config.UseServiceBus (), config.UseTimers () and etc ..).

I used to use TraceWriter logas the last parameter for my methods, but then I found out what I should use instead ILogger. Before I made the changes, I got the same error as above.

It seems to ILoggerdisplay in the assembly Microsoft.Extensions.Logging.Abstractions. Maybe that's why it is not recognized? Which ILoggershould be used? Here is the method signature.

    [FunctionName("GetLoginUrl")]
    public static HttpResponseMessage GetLoginUrl(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)]HttpRequestMessage req,
        ILogger log)

I did not try to deploy it on Azure.

Unfortunately, creating a completely new project "Functions" does not help, since there are no .CS files to search for to fix this.

+4
source share
1 answer

Microsoft.Extensions.Logging.Abstractions - this is the correct assembly.

, , NuGet (, Microsoft.Azure.WebJobs). , . , csproj , :

<ItemGroup>           
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.4" />
</ItemGroup>
+2

Source: https://habr.com/ru/post/1686543/


All Articles