You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm integrating application insights with my App service which has a WebJobs project, following these instructions.
Things are working smoothly except that the cloud_RoleName and cloud_RoleInstanceName in ai portal are not meaningful (random numeric values, and seem to be changing over time).
I used a custom TelemetryInitializer in the api role, and it is changing those values as desired. However the webjob project doesn't seem to be picking up the role names assigned in custom initializer. When debugging locally, the code does execute the custom initializer overriden values, but it seems that it is being changed when the log is being sent to ai.
Here is the custom initializer that I use: public class AppInsightsTelemetryInitializer : ITelemetryInitializer { public void Initialize(ITelemetry telemetry) { telemetry.Context.Cloud.RoleName = ConfigurationManager.AppSettings["EnvironmentName"]; telemetry.Context.Cloud.RoleInstance = $"webjob-{ConfigurationManager.AppSettings["InstanceId"]}"; } }
FYI -- cloud_RoleName should be the name of your site. And cloud_RoleInstanceName is the WEBSITE_INSTANCE_ID, which uniquely identifies the machine. It can change because you're running on different physical machines.
I'm integrating application insights with my App service which has a WebJobs project, following these instructions.
Things are working smoothly except that the cloud_RoleName and cloud_RoleInstanceName in ai portal are not meaningful (random numeric values, and seem to be changing over time).
I used a custom TelemetryInitializer in the api role, and it is changing those values as desired. However the webjob project doesn't seem to be picking up the role names assigned in custom initializer. When debugging locally, the code does execute the custom initializer overriden values, but it seems that it is being changed when the log is being sent to ai.
Here is the custom initializer that I use:
public class AppInsightsTelemetryInitializer : ITelemetryInitializer { public void Initialize(ITelemetry telemetry) { telemetry.Context.Cloud.RoleName = ConfigurationManager.AppSettings["EnvironmentName"]; telemetry.Context.Cloud.RoleInstance = $"webjob-{ConfigurationManager.AppSettings["InstanceId"]}"; } }
And it's hooked in WebJobs' Program.cs:
...
ApplicationInsights.Extensibility.TelemetryConfiguration.Active.TelemetryInitializers.Add(new AppInsightsTelemetryInitializer());
...
How can I change these values?
The text was updated successfully, but these errors were encountered: