When it comes to PaaS, one of the most popular services from Azure is Azure App Service, also known as Web Apps. They allow you to quickly get started with a server for hosting your web applications, which can be easily configured and adjusted to your needs. Besides purely development experience, Azure App Service also includes a set of features that make monitoring and diagnosis a piece of cake. In this section, I will show you how to monitor your web application and find the root cause of issues you may face.
To get started, we will need an instance of a Web App in Azure. You can deploy it really quickly using the Azure CLI:
$ az appservice plan create -g <rg-name> -n "<plan-name>" --sku <sku> $ az webapp create -g <rg-name> -n "<webapp-name>" -p "<plan-name>"
To create an instance of Azure App Service, you need two commands:
- The first one will create an Azure App Service Plan that gives you resources (CPU, memory, and storage) that can be used by your applications.
- The second one creates the actual Web App, which will host the files of your application.
Once your Web App has been created, we can focus on implementing various monitoring features and validating their availability. When it comes to monitoring PaaS services, especially Azure App Service, one of the best services is Azure Application Insights. In fact, they are available as one of the settings of your application:
Initially, this feature is disabled and requires you to install an extension to get things working. So, let’s begin:
- Install the extension directly from the Azure portal using the Turn on site extension button:
- Once you click the button, you will have to configure the plugin by providing additional information about Azure Application Insights such as resource name, the technology stack you are aiming at (.NET, .NET Core, Node.js, or Java), and enabled features (Profiler, Snapshot debugger, and so on):
- The last thing required here is clicking on the Apply button and confirming that you want to apply the changes:
Now, the process of provisioning the extension will start. This can take several minutes to complete.
Now, let’s check the actual capabilities of the feature.
Exploring capabilities of Azure Application Insights
Once your Azure Application Insights instance is ready, you can go to it and start browsing its capabilities. Let’s check it out:
- The thing we are interested in the most here is the Availability blade. You can find it in the Investigate section:
- From this screen, you will be able to perform two important actions:
- Verify the availability of your application.
- Create a test that periodically checks the status of your website.
- To create a test, click on the + Create Test button:
- From the new screen, you will be able to configure a test where you can decide how you want to access an application and specify the criteria that will mark the test as failing:
Once your availability tests have run, you will be able to see their results, as shown in the following screenshot:
Note the following things:
- Tests can be executed from different locations, which will ensure that your problem is or is not related to a region.
- You can have multiple tests covering different scenarios.
- For more advanced scenarios, upload the WEBTEST files (go to https://docs.microsoft.com/en-us/visualstudio/test/quickstart-create-a-load-test-project?view=vs-2019), which cover multi-step scenarios of testing web applications.
- When availability tests are failing, you can add email recipients who will be notified when things are not working at that moment in time.
Azure Application Insights is a powerful service that is not limited to availability tests only. In the Further reading section, you will find additional information about using additional tools such as alerts, Smart Detection, and API access. Depending on your use case, you can leverage this Azure resource as either a sink for metrics or a complex solution and a dashboard, which will cover most of your requirements when it comes to web application monitoring.
For now, we have covered monitoring features for various Azure services such as Azure VMs, storage accounts, and Azure App Service. The next topic will help you understand Azure SQL backup capabilities.