Monitoring Azure Static WebApps with Application Insights

How to use Azure Application Insights to monitor the availability of a Static WebApp, complete with alerts when it goes down, for (almost) no cost.

If you’re running a low-cost/ free Azure Static WebApp then it’s useful to be notified if the site goes down. However, your site is extremely cheap to run and your infrastructure is simple and straightforward, so how can you monitor the site without adding extra cost or complexity? The answer lies in Application Insights.

Application Insights are a comprehensive set of tools that can give you detailed usage and performance reports for your web application. But if you only need to know “Is my site down?” they can also be used to just answer that question.

This method can be used not only on Azure Static WebApps, but also to monitor any other internet-facing website. If you are hosting a more dynamic site then you might want to investigate the more in-depth features of Application Insights as well.

Setting it up

To do this for your own site you need to create an Application Insights resource and a Log Analytics Workspace (or associate it with an existing one). As with all resources, this can be done through the web Portal, PowerShell or CLI, or using ARM templates. A guide to creating the Application Insights resource can be found on Microsoft Docs.

Once this is in place you need to create a URL ping test. This isn’t a regular ICMP Ping, but is actually a HTTP request to your site. Details on setting up the test are also on Microsoft Docs.

This will start monitoring your site, and creates some default alerts. The final step is to configure the alert notifications so you are informed of any downtime. To do this locate the Alert Rule and configure an Action- for example to send you an email or a notification to the Azure app. Full instructions can be found as usual on the Microsoft Docs website

An alert rule configured to notify via email and the Azure app

Global Statistics

Microsoft test the site availability from multiple locations around the world - you can currently select up to 16. Intended to distinguish between local network issues and website problems this feature also means you can see not only if your site was unavailable in Japan (for example) but if users in Brazil are having slower access to your site.

If your site is underperforming in locations where your customers are based you might want to look at relocating it to a closer Azure region, or upgrading to the Standard hosting plan with the new Enterprise-grade edge powered by Azure Front Door for global reach. Sorry- that solution doesn’t come free!

Statistics for this site showing particularly slow access from Brazil

Costs

As stated at the top of this article, the costs of implementing this are incredibly low. As with almost all Azure resources you’re going to pay for compute, storage, and networking under the hood but these usages are so low that a site can be monitored for just a few pence a month.

The costs for a real example here. 37 pence per month for monitoring and alerting.