I have created http trigger function in .net core 3.1 but i am not able to add telemetry for logging in application insights. I am using startup class and adding package Microsoft.Azure.Functions.Extensions in csproj.
But I am getting this error
An unhandled host error has occurred. [2021-06-17T13:08:55.752Z] Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type 'Google.Apis.ShoppingContent.v2_1.ShoppingContentService' while attempting to activate 'ShoppingSamples.Content.GoogleAuth'.
Is there any way i can add logs in application insights in http trigger function?
If you'd like to make your logs from azure function(.net) be captured by azure application insights, you have to solutions:
one is adding app insights instance to azure function when you creating or created function instance in azure portal(that means codeless), see screenshot below, no other configurations.
Another is adding sdk to the function project, with the sdk you can also send custom telemetry(code-based). Don't forget to add APPINSIGHTS_INSTRUMENTATIONKEY
in local.settings.json
file when debug in local environment.