I'm encountering an issue where Azure Function App isn't forwarding logs to AppInsight. I've checked the file system logs on the function app, and they're working fine and complete. Also, I'm sure that my APPINSIGHTS_INSTRUMENTATIONKEY is configured correctly. Moreover, this only happens in the dev environment; in higher environments, it works fine. I'm using Terraform to create resources. Do you know what possibilities could lead to this issue? (network, role, configuration, etc.) Thanks a lot.
screenshot filesystem log
My host.json
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Host": "Error",
"Function": "Information",
"Host.Aggregator": "Information"
}
}
}
Startup.cs
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services
.AddLogging(lb =>
{
lb.AddApplicationInsightsWebJobs(options =>
{
options.InstrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
});
})
// Already try AddLogging()
}
my csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Kafka" Version="3.8.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.2.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EventBroker.Application\EventBroker.Application.csproj" />
<ProjectReference Include="..\EventBroker.Infrastructure\EventBroker.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>





.csprojfile. Also please share your function code.In-processorIsolated)? What .NET version?.csprojfile. I just implement log.LogInformation in function code. I have issue the log that is not forwarded to appinsight. But I already check the filesystem log in function. It work properly