- Basics about Application Insights
- Connecting to Application Insights using instrumentation key
- Analyze Application Insights data in the Azure Portal and Visual Studio
-
Discussion points:
- Discuss why telemetry and logging are important especially in Microservices architectures
- Describe the basics of Application Insights (e.g. high-level features, architecture, pricing models, etc.)
-
Open Azure Portal and sign in.
-
Add Application Insights named
PracticalDevOps-Dev
to the resource groupPracticalDevOps-Dev
.
-
Add the
InstrumentationKey
setting to yourweb.config
file.<?xml version="1.0" encoding="utf-8"?> ... <configuration> <appSettings> <add key="MinimumNumberOfBooks" value="1"/> <add key="MaximumNumberOfBooks" value="5"/> <add key="BookNameTokenUrl" value="..."/> <add key="InstrumentationKey" value="ba2c0764-5cfb-4741-a8e1-fb150b175a7d"/> </appSettings> ... </configuration>
-
Add code setting the instrumentation key to
Startup.cs
:public void Configuration(IAppBuilder app) { TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings["InstrumentationKey"]; // Allow CORS app.UseCors(CorsOptions.AllowAll); ... }
-
Add custom event tracking to
Controllers/BooksController.cs
:[HttpGet] [Route("books")] public async Task<IEnumerable<Book>> Get() { var numberOfBooks = new Random().Next(this.options.MinimumNumberOfBooks, this.options.MaximumNumberOfBooks + 1); var telemetryClient = new TelemetryClient(); telemetryClient.TrackEvent($"Generating {numberOfBooks} books"); var result = new Book[numberOfBooks]; ... }
-
Discussion points:
- Describe basics of Application Insights SDK (e.g. exception logging, metrics)
-
Run all your tests to make sure you did not break something.
-
Run application locally and refresh
http://localhost:2690/api/books
multiple times. -
See if your application telemetry appears.
-
Discussion points:
- Let people play a bit with building Application Insights dashboards in the Azure portal
- Describe concept of custom processing of Application Insights data
- Brief overview about other Application Insights modules (e.g. for IaaS)
-
Open Application Insights Search in Visual Studio while debugging your application. Refresh
http://localhost:2690/api/books
multiple times. See if your application telemetry appears.
-
Discussion points:
- Point out how calls to dependent services are tracked automatically
- Show how unnecessary calls to Blob Storage in our app become visible by analyzing Application Insights telemetry data
If you have time left, you could additionally cover topics like:
- Describe how to link Application Insights with wide-spread logging frameworks like NLog (Microsoft.ApplicationInsights.NLogTarget NuGet package)
- Demonstrate PowerBI and Application Insights
- Show Application Insights Analytics