Azure / Azure/azure-functions-host

Exceptions sent to AppInsights twice

Open
#6,564 8 comments 6 reactions 0 assignees View on GitHub
needs-investigation
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

When a function throws an exception, that exception is shown once in the console but is logged twice to AppInsights (testing that locally in Visual Studio) with different categories: *Host.Results* and *Function.Function1*.

#### Investigative information

Azure Functions Core Tools (3.0.2798 Commit hash: d9d99872a51c04b1c2783198b1ee1104da6b064f)
Function Runtime Version: 3.0.14191.0

#### Repro steps

1. Create a new C# FuncApp project in Visual Studio 2019.
2. Add `"APPINSIGHTS_INSTRUMENTATIONKEY": "local"` to `local.settings.json`.
3. Create an empty `ApplicationInsights.config` in the root folder.
4. Replace the function code with:
```
[FunctionName("Function1")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req)
{
throw new ApplicationException("Test exception.");
}
```
5. Execute the function.

#### Expected behavior

After I perform step 5, I see only one exception message both in the console window and in the `Application Insights Search` window.

#### Actual behavior

I see two identical exceptions in the `Application Insights Search` window with different categories:

![image](https://user-images.githubusercontent.com/5908454/91421684-825a2a00-e856-11ea-8669-7d4e77ec948f.png)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with local.settings.json, an empty ApplicationInsights.config, and the C# Function1 Run method described in the report. Compare the console and Application Insights Search entries, focusing on the Host.Results and Function.Function1 categories. Done means the thrown exception produces one Application Insights exception entry rather than two.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.