Error "Unable to resolve Ilogger from Microsoft.Extensions.Logging" when making a request to endpoint from Azure fucntion

Asked

Viewed 43 times

0

I have an Azure Function that has an endpoint that questions a data repository and to have Traces of what the function does I used the ILogger<T>.

The class in question has the implementation in the constructor

public class MetricsProvider
{
private readonly ILogger logger;

public MetricsProvider(ILogger<MetricsProvider> logger)
{
    this.logger = logger;
}

[FunctionName("TriggerRoseMetricsUpload")]
public async Task<IActionResult> TriggerRoseMetricsUploadAsync(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "{account}/{subscription}/TriggerRoseMetricsUpload")]HttpRequest req,
    [Queue("rose-mtr-provider", Connection = "AzureWebJobsStorage")] ICollector<string> queue,
    string account,
    string subscription)
{
   ......
}

}

When I run I have the error:

[2021-03-10T16:35:51.419Z] Executed 'Triggerrosemetricsupload' (Failed, Id=f95cb01e-d96e-42b9-8dcd-f330c05a425b, Duration=233ms) [2021-03-10T16:35:51.423Z] Microsoft.Extensions.Dependencyinjection.Abstractions: Unable to resolve service type for 'Microsoft.Extensions.Logging.Ilogger1[Primavera.Rose.AF.MTRProvider.MetricsProvider]' while attempting to activate 'Primavera.Rose.AF.MTRProvider.MetricsProvider'. [2021-03-10T16:35:51.998Z] An unhandled host error has occurred. [2021-03-10T16:35:52.000Z] Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger1[Spring.Rose.AF.MTRProvider.Metricsprovider]' while attempting to Activate 'Spring.Rose.AF.MTRProvider.Metricsprovider'.

  • you probably did not register the dependency to be injected into the job startup

  • What I don’t understand here, is that publishing for Zure works.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.