Introduction

This article's intention is to explain the main skills measured in this sub-topic of the AZ-204 Certification. Application Insights, Azure Monitor, and Transient Faults are the main components that will have their fundamentals explained here alongside a practical example.

This certification is very extensive and this article approaches only the main topics, make sure you know those components in depth before taking the exam. Another great tip is to do exam simulators before the official exam in order to validate your knowledge.

What is the Certification AZ-204 - Developing Solutions for Microsoft Azure?

The AZ-204 - Developing Solutions for Microsoft Azure certification measures designing, building, testing, and maintaining skills of an application and/or service in the Microsoft Azure Cloud environment. It approaches, among others, those components.

Target Audience

Any IT professional willing to improve his knowledge in Microsoft Azure is encouraged to take this certification, it is a great way to measure your skills within trending technologies. But, some groups of professionals are more keen to take maximum advantage of it,

Skills Measured

According to today's date, the skills that are measured in the exam are split as follows.

Benefits of Getting Certified

The main benefit here is having a worldwide recognized certification that proves that you have knowledge of this topic. Among intrinsic and extrinsic benefits, we have,

Main Skills Measured by this Topic

What is Azure Monitor?

Azure Monitor is an Azure Service focused on monitoring your applications, working on applications hosted by Azure and, also by on-premises applications. The Azure Monitor is free for built-in log collection enabled automatically but has a cost if you need to create more customized queries and alerts.

Azure Monitor collects logs from your applications, and from those logs, you can create dashboards, alerts, queries, create automated tasks, and much more, as follows.

Which data is collected from Azure Monitor?

Azure Monitor collects enough data to troubleshoot any kind of issue that could happen in your application or service as follows.

Analyze Log with Azure Monitor

Azure Monitor offers a wide variety of ways to use the logs collected from applications and services. From creating alerts to be triggered when some situations happen to creating complex queries to troubleshooting errors that happened in your application, those are the main functionalities and terminologies used to analyze logs with Azure Monitor.

What is Application Insights?

Application Insights is part of Azure Monitor tools categorized as Application Performance Management (APM), to collect live logs from your application whereas it will automatically detect some issues and track users' interactions inside your applications. It is an excellent tool to understand how your users are using your applications as far as troubleshooting problems.

To use Application Insights inside your application you have to install its SDK and configure the instrumentation inside your application, those instrumentations are going to monitor your application and send those logs to Azure Application Insights resource for better visualization. Application Insights has built-in powerful instrumentation and it also gives you the opportunity to create your customized one, Azure Application Insights built-in instrumentation tracks the following.

Instrumentation in Application Insights

Application Insights has a wide range of instrumentation tools, each one with its own importance and functionality. Below you will find the most common instrumentation tools from Azure Application Insights.

Web Tests and Alerts in Application Insights

Application Insights is always monitoring your application, and external resources used by your applications if applicable, and you can configure alerts to be notified when something is not going as expected. For example, you can create an alert to be triggered when the application goes down or if the application is slower than normal, those features are also extendable to your external resources.

With Application Insights Web Tests, you can create multi-step web tests using Visual Studio for your web services in order to validate if your external sources are still valid and have not changed. It is important to notice that Multi-Step Web Tests are deprecated and will not be available in future versions of Visual Studio.

There is another type of Web Test, the URL Ping test that is a great way to automate an availability health check for your applications. With Application Insights URL Ping Availability Tests, you can customize the frequency, acceptance criteria, URL, and locations that this test will run.

Application Insights Alerts is another tool to monitor your application, you can select from a wide range of pre-built conditions to customize your alerts and, select the action group to be executed when those conditions are met.

What are Transient Faults?

Transient Faults is the name given when your application tries to access an external source without success, those errors are usually transients and related to connectivity issues and must be handled correctly in order to avoid a bad user experience with your application. Transient faults can be handled with a simple retry engine and most of the remote services already have a built-in strategy mechanism to address it.

Handling Transient Faults' main good practices.

Practical Samples

Application Insights With .Net Core Web API

Pre-Requisites

Application Insights Creation from Azure Portal

From your Azure Portal, go to Application Insights and create a new one. Fill out the form and create it.

 Azure Portal

Application Insights Creation from PowerShell.

New-AzApplicationInsights -Kind web -ResourceGroupName appInsights -Name sampleAppInsights -location westeurope

Application Insights Configuration

From your Application Insights Resource, get your instrumentation key.

Application Insights Resource

Set your configuration key in appSettings.json.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "ApplicationInsights": {
    "InstrumentationKey": "0f31185f-c48f-4430-ac18-6c7b1cdfb618",
    "EnableAdaptiveSampling": false,
    "EnablePerformanceCounterCollectionModule": false
  },
  "AllowedHosts": "*"
}

Update your Startup. cs to initialize telemetry.

public void ConfigureServices(IServiceCollection services)
{
    // Enables Application Insights telemetry collection
    services.AddApplicationInsightsTelemetry();
    services.AddControllers();
}

And.. that's all! It is that easy to configure Application Insights to collect data from your project and you can check the live metrics feature from your Azure Application Insights resource.

Azure Application

Application Insights Web Tests

Using Azure Portal, from your Application Insights resource go to Availability under Investigate and then click on Add test.

Web Tests

Application Insights Alerts

Using Azure Portal, from your Application Insights resource go to Alerts under Monitoring and then click on New Alert Rule.

Monitoring

Result when the alert is triggered.

Triggered

Azure Monitor

Collecting Activity Logs with Azure Monitor.

From Azure Portal, go to your Azure Monitor, then go to Activity Logs.

Azure Monitor

Using Azure CLI

az monitor activity-log list

Creating a Metric Chart with Azure Monitor

From Azure Portal, go to your Azure Monitor and then Metrics. Click on New Chart and then configure your metric chart.

New Chart

Creating Alerts with Azure Monitor

To create an alert based on a metric chart using Azure Portal, from your Metric Chart click on the button New Alert Rule

Metric Chart

Configure the Action and create the alert.

Configure

Log Query With Azure Monitor

From your Azure Monitor, go to Logs. Azure Monitor has some built-in queries for usage as follows.

Log Query

If we select on and click on Run we have the result.

Run

Transient Faults

Handling Transient Faults usually are specific to each type of component that we are trying to access, each component has its own code to handle the faults. So I present to you two articles from friends that explain different types of handling transient faults.

External References