Challenge 04 - Azure Monitor for Applications

< Previous Challenge - Home - Next Challenge >

Introduction

To ensure performance requirements are met for eShopOnWeb, you will need to detect performance anomalies, diagnose issues, and understand what users are actually doing on the website. You will deploy and configure Application Insights to allow for continuous performance and usability monitoring.

Application Insights is an extension of Azure Monitor and provides application performance monitoring (APM) features. APM tools are useful to monitor applications from development, through test, and into production in the following ways:

Application Insights is enabled by adding the Application Insights SDK or Azure Monitor OpenTelemetry Distro to your application code. Many languages are supported. The applications could be on Azure, on-premises, or hosted by another cloud.

NOTE: As of September 2023, the Azure Monitor OpenTelemetry Distro is in preview. For this hack, we recommend using the Application Insights SDK for .NET. In the future, OpenTelemetry will be a fully supported option for monitoring applications in Azure Monitor.

Description

An Application Insights resource has been pre-deployed in your eShopOnWeb Azure environment. It is named: ai-wth-monitor-d-XX

The source code for the eShopOnWeb application is located on the Visual Studio VM (vmwthvsdXX). You will connect to this VM via Azure Bastion and use Visual Studio to complete the tasks of this challenge.

For this challenge, you will need to complete the following high level tasks:

Create an Application Insights Availability Test

With Application Insights, you can set up recurring tests to monitor availability and responsiveness. Application Insights sends web requests to your application at regular intervals from points around the world. It can alert you if your application isn’t responding or responds too slowly.

You can set up an availability test for any HTTP or HTTPS endpoint that is accessible from the public internet. You don’t have to make any changes to the website you are testing. In fact, it doesn’t even have to be a site that you own. You can test the availability of a REST API that your service depends on.

Enable Application Insights Server-Side Telemetry for eShopOnWeb

HINT: There are two ways to complete these tasks:

NOTE: If you log into Azure with a work or school account that is NOT in the same Entra ID (formerly Azure Active Directory) tenant where your Azure subscription is located, you will not be able to use the automated tools & wizard in Visual Studio.

Enable Application Insights Client-Side Telemetry for eShopOnWeb

If your application has client-side components, such as JavaScript, Application Insights can collect telemetry from them too.

This can be done simply by adding a JavaScript snippet that loads on all pages of your website.

Test eShopOnWeb on the Development Server

We have added an “Easter Egg” in the eShopOnWeb application that will trigger an exception.

Create Alerts

Now that you have Application Insights configured and are able to view that the exceptions appear in the Azure Portal, you want to be able to respond to them.

Publish the Updated eShopOnWeb Website to the VM Scale Set

Once you have implemented Application Insights for the eShopOnWeb website in Visual Studio, you will need to get your changes published to the VM scale set hosting the website.

The VM scale set’s automation script is configured to download the eShopOnWeb website from a fileshare on the Visual Studio VM.

In the /Challenge-04 folder of your student resource package, you will find a PowerShell script named BuildAndPublish-eShopOnWeb.ps1. This script builds the solution and publishes its artifacts to the fileshare on the Visual Studio VM so that the VM scale set’s automation script can download it.

Observe Application Insights Telemetry from the VM Scale Set

Success Criteria

Learning Resources

Advanced Challenges

Too comfortable? Eager to do more? Try these additional challenges!