Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can VSO Application Insights be used from a console application?

All the information that I can find on Application Insights seems to be targeted at websites / windows store / phone apps. I would like to monitor an Azure webjob, with the first step being able to monitor a command line app. What do I need to do in order to make this work?

like image 640
Joshka Avatar asked Aug 12 '14 03:08

Joshka


People also ask

How do I add application insights to an existing project in .NET core?

Open your project in Visual Studio. Go to Project > Add Application Insights Telemetry. Choose Azure Application Insights, then select Next. Choose your subscription and Application Insights instance (or create a new instance with Create new), then select Next.

How do I enable application insights?

Select Application Insights in the left pane for your app service. Then select Enable. Create a new resource or select an existing Application Insights resource for this application. When you select OK to create a new resource, you're prompted to Apply monitoring settings.

How do I view application insights logs in Visual Studio?

Run your web app in local debug mode by using F5. Open different pages to generate some telemetry. In Visual Studio, you see a count of the events that have been logged by the Application Insights module in your project. Click this button to search your telemetry.


1 Answers

To use Application Insights in a Console application,

  • Create a new Application Insights resource as described here.

  • Use the NuGet package manager reference the Microsoft.ApplicationInsights package in your console application.

  • In the beginning of Program.Main, configure Application Insights to use the instrumentation key of your resource.

TelemetryConfiguration.Active.InstrumentationKey = "your key";

  • Create instance of TelemetryClient in the application code and call relevant Track methods as described here.
like image 151
Oleg Sych Avatar answered Nov 12 '22 11:11

Oleg Sych