I have an Azure Function v2, like this:
public sealed class FindAccountFunction
{
private readonly IAccountWorkflow m_accountWorkflow;
public FindAccountFunction(ILogger<FindAccountFunction> logger)
{
m_logger = logger;
}
[FunctionName("FindAccount")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "GET", Route = "v1/accounts/")] HttpRequest httpRequest)
{
// Do stuff.
m_logger.LogInformation("Duuuddde");
}
}
As described in a different question, the logger is being injected:
[assembly: WebJobsStartup(typeof(Startup))]
public sealed class Startup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder webJobsBuilder)
{
// Registers other services...
// -- UPDATE - The AddLogging must be called here --
webJobsBuilder.Services.AddLogging();
}
}
Then I trigger my function through an HTTP request and go to the Function's portal on Azure DevOps to see if the logs is actually printed:
I only see the logs indicating that the function ran successfully however I do not see my log.
Question
Why is the ILogger
injected in my Azure Function v2 missing the APPINSIGHTS_INSTRUMENTATIONKEY
?
Update
When I look at the injected ILogger
, I can see that the InstrumentationKey of the Application Insights Provider is not set. The same applies for a ctor injected ILogger, but also for the injected ILogger
in the Run method.
For my local tests, the instrumentation key is declared in the local.settings.json
file: