Hello,
I have a problem connecting Application Insights with the app server. I can successfully connect the application and am able to exploit the data and make queries from Application Insights. Currently, in the requests table, I obtain all these data except for the session_Id and user_Id. When debugging the application, I see that the httpcontext of the application's session is null and it cannot assign to telemetry either. This would be the initializer that correctly has the user but within the context, the session is null.
public class CustomTelemetryInitializer : ITelemetryInitializer
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ICurrentUser _currentUser;
public CustomTelemetryInitializer(IHttpContextAccessor httpContextAccessor, ICurrentUser currentUser)
{
_currentUser = currentUser;
_httpContextAccessor = httpContextAccessor;
}
public void Initialize(ITelemetry telemetry)
{
var httpContext = _httpContextAccessor.HttpContext;
if (httpContext == null) return;
if (_currentUser.IsAuthenticated)
{
telemetry.Context.User.AuthenticatedUserId = _currentUser.Email;
telemetry.Context.GlobalProperties["TenantId"] = _currentUser.TenantId.ToString();
}
}
}
As information, on the client side, I have the session without problems.
Thanks,