I am trying to log the message from the the Configure class to Application Insights. While the messages are properly logged inside the Run method, but where am adding the polly, Its not sending the message to Appinsights.
//am able to log the message from here.
[FunctionName("Function1")]
public async Task Run(string msg,
ILogger log)
{
log.LogInformation("An error occurred.");
}
// But not from here.
[assembly: FunctionsStartup(typeof(Startup))]
namespace TestFunc2
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.HTTPExtension();
}
}
public static class DependencyExtension
{
public static IServiceCollection HTTPExtension(this IServiceCollection services)
{
services.AddHttpClient<Function1>("client", (provider, client) =>
{
var logger = provider.GetService<ILogger<Function1>>();
logger.LogInformation("func2");
logger.LogError("func2");
client.BaseAddress = new Uri("http://www.ggl.com");
client.DefaultRequestHeaders.Add("Accept", "application/json");
});
return services;
}
}
}