Can I implement application insights for Windows Service .
I would like to know if I can leverage this feature to get insights in to service when the error is logged to event viewer or to provide the status information.
I have reviewed examples in MSDN for web application and also reviewed the post .
You can use the Application Insights (AI) SDK for that, you will need to add the proper NuGet package to your project. Do mind that you have to send the telemetry yourself. So you need to catch your exceptions and send them to AI. Same applies to status changes of the service.
When you create an AI environment in the Azure Portal you have to choose an Application Type. I suggest you choose "General". It does nothing more that predetermine the layout if the AI site, it does not restrict things in any way.
To send telemetry data you can use the appropriate methods like for Exceptions:
TelemetryClient telemetry = new TelemetryClient
{
InstrumentationKey = "<your key for AI>"
};
try
{
...
}
catch (Exception ex)
{
telemetry.TrackException(ex);
}
To send statusinformation of your service you can do:
telemetry.TrackTrace("Service Started", SeverityLevel.Information);
I suggest you take a look at the docs for more info.