Updated 14. Using Application Insights in eShopOnContainers (markdown)

RamonTC 2017-12-01 12:53:03 +01:00
parent 9728c29923
commit 141a611089

@ -2,6 +2,23 @@
Follow the steps bellow to configure App Insights as a logging service. It is included the instructions for setting up App Insights in case you decide to register eShopOnContainers logs locally, or for instance in a cluster environment with Kubernetes or Service Fabric. Follow the steps bellow to configure App Insights as a logging service. It is included the instructions for setting up App Insights in case you decide to register eShopOnContainers logs locally, or for instance in a cluster environment with Kubernetes or Service Fabric.
### Add App Insights to an aspnetcore app
Install the following nuget packages:
* Microsoft.ApplicationInsights.AspNetCore
* Microsoft.ApplicationInsights.DependencyCollector
In case of deploying your app in a cluster environment, install these additional packages:
* Microsoft.ApplicationInsights.Kubernetes (for a Kubernetes environment)
* Microsoft.ApplicationInsights.ServiceFabric (for a Service Fabric environment)
Include the **UseApplicationInsights** extension method in your webhostbuilder located at program.cs:
<img src="https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/img/appinsights/useappinsights-program.PNG">
Register AppInsights service by including the **AddApplicationInsightsTelemetry** extension method in your ConfigureServices Startup method located at Startup.cs. In case of using K8s or SF, add **EnableKubernetes** or **FabricTelemetryInitializer** method respectively:
<img src="https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/img/appinsights/appinsights-register.PNG">
To enable the AppInsights in your ILogger,include the **AddAzureWebAppDiagnostics** and **AddApplicationInsights** IFactoryLogger extension method in your Configure Startup method located at Startup.cs:
<img src="https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/img/appinsights/appinsights-loggerfactory.PNG">
### Create an App Insights service ### Create an App Insights service
Go to the Azure portal and create the service: Go to the Azure portal and create the service:
- Create Azure AppInsights - Create Azure AppInsights