Azure / Azure/azure-functions-dotnet-worker

Cloud role name and operation id not provided for exceptions

Open
#3,084 0 comments 3 reactions 0 assignees View on GitHub
Needs: Triage (Functions) potential-bug
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description

For the exceptions that have a call stack similar to this:

> at Redacted.Run(EventData[] messages) in /Redacted.cs:line 95
at Redacted.DirectFunctionExecutor.ExecuteAsync(FunctionContext context) in /REDACTED/obj/Release/net9.0/linux-x64/Microsoft.Azure.Functions.Worker.Sdk.Generators/Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionExecutorGenerator/GeneratedFunctionExecutor.g.cs:line 39
at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 96
at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\a\_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 89

The cloud role name and operation id is not provided in application insights.

Using package:
``

Observed on both consumption and non consumption app plans.
On linux, Dotnet 9.
Function runtime: 4.1039.500.1

Also possible with a timer trigger

Also found this:
https://github.com/microsoft/ApplicationInsights-dotnet/issues/2774

I have a feeling that: https://github.com/Azure/azure-functions-dotnet-worker/blob/main/src/DotNetWorker.ApplicationInsights/FunctionsRoleInstanceProvider.cs is not being called before this exception happens.

This makes correlation of exceptions / traces a pain in the ...

### Steps to reproduce

1. Start from a new azure function template
2. Configure application insights
```(c#)
.ConfigureServices((context, services) =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
```
4. Add a function with an exception
```(c#)
public class CalculatorFunction
{
[Function("Reproduce")]
public async Task Run([TimerTrigger("%TimerConfig%"
#if DEBUG
, RunOnStartup = true
#endif
)] TimerInfo myTimer)
{
throw new InvalidOperationException("No cloud role name");
}
}
```

5. deploy to azure with an application insights connection string configured.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/DotNetWorker.ApplicationInsights/FunctionsRoleInstanceProvider.cs and reproduce the issue from a new Azure Function using the shown Application Insights configuration and timer-triggered exception. Trace whether the provider runs before the exception and verify that Application Insights records both the cloud role name and operation ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
observability
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.