Usually when adding Application Insights (even without configuring it) in a ASP.Net Core website, the Application Insights Search window in Visual Studio shows all the telemetry gathered (requests, exceptions, etc.).
When developing an Azure function the same window stays desperately empty and no telemetry shows up. I've checked the TelemetryConfiguration in both case and both looks the same. I highly suspect that it's a matter of host process/child process for running the function which isolate and makes it unable to see what's going on.
Am I missing something ? Is it worth opening a bug/feature request in any GitHub repo ?
In your function app, select Configuration under Settings, and then select Application settings. If you see a setting named APPINSIGHTS_INSTRUMENTATIONKEY , Application Insights integration is enabled for your function app running in Azure.
Select Application Insights from the Settings, then select View Application Insights data. This link takes you to your separate metrics resource created for you when you created your Azure Function with VS Code. Select Logs in the Monitoring section.
Querying the logs To query the generated logs: From your function app, select Diagnostic settings. From the Diagnostic settings list, select the Log Analytics workspace that you configured to send the function logs to. From the Log Analytics workspace page, select Logs.
If the azure function is published to azure, then I suggest you DO NOT configure application insights locally in your function. Just follow this doc.
In your case, you develop the azure function locally in visual studio, and wan to test it application insights locally, then please follow this steps below(Note again: this is just for testing purpose, but before it is published to azure, you should remove all the settings, just publish a clean function to azure -> then configure application insights by this doc):
Step 1:Create a function in visual studio, here I created a blob trigger azure function, version v3.
Step 2:Then install this package Microsoft.Azure.WebJobs.Logging.ApplicationInsights.
Step 3:Add a file to the root of the function, the file name is ApplicationInsights.config
.
The content:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
</ApplicationInsights>
Here is a screenshot of the file and it's content:
Step 4:In local.settings.json, add "APPINSIGHTS_INSTRUMENTATIONKEY":"any value here, even it is not a real key"
. Here is a screenshot:
Step 5:Here is the screenshot of my code in function.cs:
Step 6:Run the function locally, and then nav to "Application insights search", you can see the messages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With