问题
Is it possible to instrument a windows service running on premise with Application Insights? It's not necessary to have it automatically collecting metrics of the application like it does with Web applications, pushing custom events to Azure would suffice.
回答1:
I'll make the docs a bit more clear on this. You can instrument anything if there's a core SDK that will build with it. So any kind of .NET, Java, PHP, OSX, iOS, Android, .... If you want additional modules that log web requests, crashes, etc, you're a little bit more restricted.
For Windows Services on premises, follow what you see here: https://docs.microsoft.com/en-us/azure/application-insights/app-insights-windows-desktop
回答2:
Install Core SDK nuget. Then create TelemetryClient, set instrumentation key programmatically and start sending telemetry from places you want. Msdn article describes how to use AI API. There will be no autocollection but everything should work.
回答3:
This totally possible! Quoting the Application Insights web page:
Monitor ASP.NET or J2EE web apps hosted anywhere: on Azure, or on other cloud services, or your own on-premises servers
You just need to create an instrumentation key on the Azure Portal and integrate the matching SDK into your app. Then the actual telemetry data is sent to the backend servers which are hosted as part of Azure.
来源:https://stackoverflow.com/questions/30704977/instrumenting-windows-service-with-application-insights