diff --git a/14.-Using-Application-Insights-in-eShopOnContainers.md b/14.-Using-Application-Insights-in-eShopOnContainers.md index a3da0fd..f503e1d 100644 --- a/14.-Using-Application-Insights-in-eShopOnContainers.md +++ b/14.-Using-Application-Insights-in-eShopOnContainers.md @@ -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. +### 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: + + +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: + + +To enable the AppInsights in your ILogger,include the **AddAzureWebAppDiagnostics** and **AddApplicationInsights** IFactoryLogger extension method in your Configure Startup method located at Startup.cs: + + ### Create an App Insights service Go to the Azure portal and create the service: - Create Azure AppInsights