Monitor your web app's availability and responsiveness
Application Insights is in preview.
Caution |
|---|
This is about the older version of Application Insights in Visual Studio Online. There’s a new version in Microsoft Azure. How do I know which I’m using, and how do I choose? |
Is your server still running? Is it responding properly, and fast enough? Microsoft Application Insights tests your web application or website at regular intervals. If the site goes down or responds slowly or incorrectly, you'll receive an email alert. And you'll get graphs showing its availability and responsiveness over time.

You can set up availability monitoring for any web service, such as a website, or the web component of your phone app. It doesn't matter whether your service is running in Azure or on your premises. It doesn't even have to be your own service. You don't have to alter the web service in any way.
There are two ways to set up an availability test or synthetic monitor:
A Single URL test accesses one web page. The test verifies that a response is received from the web server within a standard interval. It can also verify the HTTP return code and perform a simple test on the text content of the web page.
A Visual Studio web test accesses a sequence of pages, for example to simulate searching for an item and adding it to a shopping cart.
If you already added Application Insights to your web app, then your application component is already registered in Application Insights.
Go to the Availability page, select your application component, and follow the instructions to set up a simple synthetic monitor.

When the monitor starts running, the setup instructions will be replaced by the test results.
Then you might want to add another single URL monitor, or add a multi-step test.
Normally it’s easiest to add an availability test after you’ve set up usage or performance monitoring for your app. But it is also possible to set up a separate application component that only runs availability tests.
Add an application component and choose to set up website monitoring.

Enter an application name for the website and the URL of the site you want to monitor.

Ignore the other steps of the procedure.
Go to the Availability page and select the application you created.

The first results will appear in about a minute. Select the specific test to see these results. Processed summary results in the parent node take longer.
Then you might want to add another single URL monitor, or add a multi-step test.
You might want to refine some of the details of your test.
Select a test and edit it. (Notice that you have to choose a child test, not the parent application.)

Provide a string that should appear in the page returned from the URL.

What are the locations about?
Application Insights sends a request to the website from those locations, in the same way that users will access the site from different parts of the world. If your site becomes unavailable in the USA but still available in Europe, you'll know that the problem is a network issue, rather than in your server.
What HTTP status code should I test for?
Typically you’ll want to test that the HTTP status code equals 200, which signals that the server recognized the URI and returned a page.
Can I use wildcards in the content match string?
No. You can test any plain text.
You can define more than one test for the same application. For example, you could test your site's home page, and also test a page that exercises your site's database, such as a product catalog.
The Availability page shows a summary of the tests for the application you select. Your new test will show results after about a minute.

How do I zoom in/out?
Drag across part of the small summary graph. You can also change the date range at top right.
How do I know if my server is responding correctly to the tests?
Red crosses represent availability tests that have failed. A test can fail because there was no response, or because the returned page didn't contain the expected content.
Why can’t I open a red cross to see the detailed error report?
First select a specific test such as ‘HomePage’ or ‘ProductCatalog’ – not the whole application. Then you can open the details of specific results.
You can hide the results from any individual monitor.

Select any test to see detailed results.

To open the result of that test, choose a red cross or a green dot.

I’m clicking a red cross but it doesn’t open the test results.
Make sure you select a specific test (such as ‘HomePage’ in our example). You can’t open the results when you select the whole application such as ‘FabrikamIceCream’.
Look at the Details and Results tabs to see the results of the test.
To see the stack trace in the context of the code, download the result and view it in Visual Studio Ultimate.
You can monitor a scenario that involves multiple steps. For example, if you are monitoring a sales website, you could test that adding items to the shopping cart works correctly.
To create a multi-step test, you record the scenario by using Visual Studio, and then upload the recording to Application Insights. Application Insights will replay the scenario at intervals and verify the responses.
Use Visual Studio Ultimate to record a user session.
Create a web performance test project.

Start recording.

Internet Explorer opens, with the web test recorder add-in.
Do the user actions you want to simulate in your test—open your website, and so on. Then stop your test.

Don't make a long scenario. There's a limit of 100 steps and a two-minute timeout.
Run the test in Visual Studio to make sure it works.

The web test runner opens a web browser and repeats the actions you recorded. Make sure it works as you expected.
Your test is recorded in a .webtest file in the Visual Studio project.
(Know all about web tests? OK, here are some things to avoid: Don't insert loops in your code, and don’t include references to other tests.)
Suppose you’re testing a tool that gets time-dependent data such as stocks from an external feed. When you record your web test, you have to use specific times, but you set them as parameters of the test, StartTime and EndTime.

When you run the test, you’d like EndTime always to be the present time, and StartTime should be 15 minutes ago.
Web Test Plug-ins provide the way to do this.
Add a web test plug-in for each variable parameter value you want. In the web test toolbar, choose Add Web Test Plugin.

In this example, we’ll use two instances of the Date Time Plug-in. One instance is for “15 minutes ago” and another for “now”.
Open the properties of each plug-in. Give it a name and set it to use the current time. For one of them, set Add Minutes = -15.

In the web test parameters, use {{plug-in name}} to reference a plug-in name.

Now upload your test to the portal. It will use the dynamic values on every run of the test.
Performance and exception monitoring with Application Insights
Set up deployment markers on your charts, so that you can see how changes you make affect performance and usage.
Yes, on the alerts page.
You can upload a configuration file.
No, we don’t support plug-ins or coded tests at present.
Caution


