Azure / Azure/Azure-Functions

Cloud role name in application insights

Open
#2,497 11 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

After enabling application insights in a NET 8 Azure function in isolated mode, the cloud role name set fot the telemetry is the name of the function app in azure. I am not able to change it using a Telemetry Initializer as documented in https://learn.microsoft.com/en-us/azure/azure-monitor/app/app-map?tabs=net#set-cloud-role-names.

TelemetryInitializer:

```csharp
public class CloudRoleNameTelemetryInitializer : ITelemetryInitializer
{
public void Initialize(ITelemetry telemetry)
{
telemetry.Context.Cloud.RoleName = "MyRolName";
}
}
```

Function app program

```csharp
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.AddSingleton();
})
.Build();

host.Run();
```
Requests are using the funcion app name as the cloud role name.
However traces (logs) are using the cloud role name I set in the telemetry initializer

![image](https://github.com/Azure/Azure-Functions/assets/11868679/b0a5dccc-0c0b-4818-b6c7-761d1edb05e1)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.