Thursday, September 26, 2019

Integrate an Azure Alert with action group in Availability Test  in Azure

This is really interesting to implement to check an availability of you webapp/AppService . Azure leverage you to do this. You can set up recurring tests to monitor an availability on intervals from difference geographical point around the world.
An Important factor is , it can raise an alert on that basis if certain condition doesn’t meet.

An excerpt from

Types of availability tests:
There are three types of availability tests:
·         URL ping test: a simple test that you can create in the Azure portal.
·         Multi-step web test: A recording of a sequence of web requests, which can be played back to test more complex scenarios. Multi-step web tests are created in Visual Studio Enterprise and uploaded to the portal for execution.
·         Custom Track Availability Tests: The TrackAvailability() method can be used to create your own custom availability tests.

NOTE: You can create up to 100 availability tests per Application Insights resource.

Prerequisites: Application Insights resource

In order to create Test , first create an application insight for the specific resource. I assume you understand how to create an application insight for AppService.

As soon as you have created Application Insight, its time to create a availability test case in azure using Azure Portal.

You can see an application insight option in AppService left pane as depicted in image app-insights

Click on that and it will take you on the following screen as shown below screen view-app-insights

Click on View Application Insights data and proceed further to see detailed application insights refer screen  below detailed-app-insight

Kindly find Availability option on the left panel of screen and click , once you click it will open a screen to create Add Test . Fill the required details of your endpoint to verify its availability from different geography. Refer screen add-test

Refer an image below to understand what value we should fill for the respective fields which appears on the screen. Add-test-complete-details

Each field is self explanatory though there are few which may be bit confusing so follow the below excerpt:

Parse dependent requests : When enabled, the test requests images, scripts, style files, and other files that are part of the web page under test. The recorded response time includes the time taken to get these files. The test fails if all these resources cannot be successfully downloaded within the timeout for the whole test. If this option is not enabled, the test only requests the file at the URL you specified.

Enable retries for availability test failures : If the test fails, we’ll try it again after 20 seconds. We’ll record a failure only if it fails three times in a row.

Success criteria

Test timeout
Decrease this value to be alerted about slow responses. The test is counted as a failure if the responses from your site have not been received within this period. If you selected Parse dependent requests, then all the images, style files, scripts, and other dependent resources must have been received within this period.
HTTP response
The returned status code that is counted as a success. 200 is the code that indicates that a normal web page has been returned.
Content match
A string, like "Welcome!" We test that an exact case-sensitive match occurs in every response. It must be a plain string, without wildcards. Don't forget that if your page content changes you might have to update it. Only English characters are supported with content match

Availability test results

Test results can be seen in form of Scatter plot and Line views, After a few mins click refresh your test results.

It appears with the following details refer screen availability-test-successful.

Edit an Alert in Availability test

Azure allows you to integrate an alert with a ping test for AppService , To achieve that just click on “…” and edit alert , a new window will appear where you can set your alert mechanism to get a notification. Refer edit-alert screen shot below:

Enable it and select an action group or create an action g
To create an action group refer this page .
In short action group is collection of different notifications or intimation to group of members, Action group takes an anticipated action to resolve issue for an alert already raised .Refer a screen shot action-group as shown below.

After choosing desired action group than save an alert. Each alert specifies a condition like  Whenever the Failed locations is Greater than or equal to 2 count
If an above condition doesn’t meet while availability test it triggers an alert to send a notification to Action Group.

I hope it will help you to manage alerting system in Availability Test case.

To edit, temporarily disable, or delete a test click the ellipses next to a test name. It may take up to 20 minutes for configuration changes to propagate to all test agents after a change is made.

I hope it will help you while you create Test case for your application.