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:

serviceBuilder.AddApplicationInsightsTelemetry();in the FunctionsStartup declared type. - Nathanael Marchand