0
votes

I have an MVC app running on local IIS server. I have an existing App Insights resource on Azure where I want Telemetry from my app to show up. However, Trace messages are not showing up on Azure Portal. I have added ApplicationInsights to my project, specified the resource where Telemetry should show up in ApplicationInsights.config and also written a TelemetryWrapper that I use in my code to send out the actual Telemetry Info and Error messages.

I initialize the Telemetry service through the wrapper:

  TelemetryWrapper.InitializeTelemetry("InstrumentationKey", "ApplicationName");

And send out messages from the wrapper too

  TelemetryWrapper.TelemetryInfo(requestId, action, userId, ultimateId, systemId, payload);

An overview of the TelemetryWrapper:

  public static void InitializeTelemetry(string apiKey, string appId)
    {
       bool postBackground = true;
        _telemetry = new TelemetryHelper(apiKey, appId, false) { PostBackground = postBackground };
    }

  public static void TelemetryInfo(Guid requestId, string action, Guid userId, string ultimateId, string systemId,
        string payload)
    {
      var telem = CreateInstance(requestId, action, ultimateId, userId, systemId, payload);
      _telemetry.Info(telem);
    }

What am I possibly doing wrong?

1

1 Answers

1
votes

Need more information. all you've shown is your code, there's no AppInsights code here to look at. so it could be that your TelemetryHelper class isn't setting the ikey correctly, the ikey could be invalid.

However: The one thing that jumps out at me is your usage of the terms apiKey and appId in your code.

Those 2 things have specific meaning in application insights, but that is for reading data from the AI API services (and apiKey in that context is something you could consider a secret, as if someone has those keys they can read all of your data!) I'm not sure if you're using them in a different context here but that jumped out at me right away.

There's a different thing, "Instrumentation Key" or iKey that you use to send data to application insights. Are you possibly switching those things around and trying to use an AI appId and apiKey in place of an iKey?

One way to check is to use fiddler or some other tool locally to watch outbound http traffic. configure it to decrypt https, and watch for outbound calls to dc.services.visualstudio.com, which is where your telemetry is going. If you have outbound calls, then it is at least trying to send your telemetry. If those calls are failing, the response might tell you that the iKey you are using is invalid, if this is the case.

You do not need