3

I am completely new to Azure Application Insight and trying to send TrackEvent from via my Local Computer. But Azure Application Insight does not seem to receive anything.

Here is my required. Spec. My sample asp.net framework console code with application insight sdk nuget installed is setup with Telemetry client and Instrumental Id configured. After console runs, Azure application insight should show a history as intended. But itsnot showing anything. Am I missing something?

My simple console Code

Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = "c453fec7-ea68-4c06-83e4-2938eef1f124";
        TelemetryClient telemetry = new TelemetryClient();
        telemetry.Context.User.Id = "Test User Id.";
        telemetry.Context.User.Id = "Test Device Id.";
        telemetry.TrackEvent("Test TrackEvent");

InstrumentationKey is correct. Telemetry.TractEvent method does not expose exception. Azure Application Insight Search(for custom event) does not show history.

Thank you.

1
  • If the answer worked for you, please mark it as answer. So it would be useful for others. Thanks. Aug 29, 2018 at 0:49

1 Answer 1

5

The cause maybe due to one of the following:

  1. For .net console app, when create a Application Insights in portal, you should select "General" for Application Type. Please refer screenshots below. enter image description here

2.In your console code, you should add Flush() and sleep() method.

        static void Main(string[] args)
        {
            TelemetryConfiguration.Active.InstrumentationKey = "your key";
            var telemetryClient = new TelemetryClient();
            telemetryClient.Context.User.Id = "uid1";
            telemetryClient.Context.Device.Id = "did1";
            telemetryClient.TrackEvent("AtestEvent7");
            telemetryClient.Flush();

            System.Threading.Thread.Sleep(5000);
        }

Then wait for a while, I can see the custom event in portal: enter image description here

BTW, I noticed that you define telemetry.Context.User.Id twice in your code, maybe a typo.

3
  • Selecting application type will have no impact on functionality - its used to show the default UI layout only.
    – cijothomas
    Aug 27, 2018 at 17:01
  • You can refer to this link. But if as you said, you can skip it. Just follow step 2. Thanks. Aug 28, 2018 at 0:40
  • Thank you for pointing it out! Confirming that application type doesn't have any effect on this functionality anymore. We'll update the documentation.
    – ZakiMa
    Aug 28, 2018 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.