It is essentially an extensible Application Performance Management (APM) service that seamlessly integrates with your app, generating valuable insights about app usage and performance. Thus, the ability to configure an app or service to use Application Insights is a core skill for the AZ-204: Developing Solutions for Microsoft Azure exam.
Configuring Application Insights
In order to use Application Insights, you must first configure it within your app or service. This procedure involves different steps based on whether you’re using a .NET Core app, a .NET Framework app, or another type of app.
1. Configuring Application Insights for .NET Core
First, you need to install the NuGet package for Application Insights. This can be done through the command line or via NuGet Package Manager in Visual Studio:
dotnet add package Microsoft.ApplicationInsights.AspNetCore
Next, adapt your Startup.cs file in your .NET Core app:
public void ConfigureServices(IServiceCollection services)
{
// The following line enables Application Insights telemetry collection.
services.AddApplicationInsightsTelemetry();
// This code adds other services for your application.
services.AddMvc();
}
2. Configuring Application Insights for .NET Framework
In this case, you can utilize the Application Insights SDK for .NET Framework. This can be installed from NuGet:
Install-Package Microsoft.ApplicationInsights.Web
Then, go to the ApplicationInsights.config file in your project, and locate the `
3. Configuring Application Insights for Other Apps
For non-.NET applications, you can configure Application Insights by adding a snippet of JavaScript code to your web application.
Replace `INSTRUMENTATION_KEY` with your actual key.
Key Takeaways
Whether you’re developing with .NET Core, .NET Framework, or another platform, the process of configuring an app to use Application Insights involves acquiring a reference to your Application Insights resource through an Instrumentation Key. This key allows the application to send telemetry data to Application Insights, which then processes and stores this data for later retrieval and analysis. This is an integral part of building scalable and maintainable Azure solutions, and is therefore featured heavily in the AZ-204 exam. By understanding and practicing with Application Insights, you’ll be one step closer to passing this exam and obtaining your Azure Developer certification.
Practice Test
True or False: Azure Application Insights is a feature of Azure Monitor.
- Answer: True
Explanation: Azure Application Insights is an extensible Application Performance Management (APM) service for developers and DevOps professionals, and is indeed a feature of Azure Monitor.
When configuring an app or service to use Application Insights, do you need to instrument your application?
- Answer: Yes
Explanation: You need to instrument your application to use Application Insights. It can be done either at build-time or at run-time.
When should you consider sampling in Application Insights?
- Answer: When you have a high volume of telemetry.
Explanation: Sampling is an effective way to reduce the volume of telemetry sent from your app and retained in Application Insights, without losing significant diagnostic information.
When installing the Application Insights SDK, what are the supported languages?
- A. C#
- B. Python
- C. Node.js
- D. Java
- E. Swift
Answer: A, B, C, D
Explanation: The Application Insights SDK supports several languages including C#, Python, Node.js, and Java.
True or False: Application Insights can be used to monitor live applications.
- Answer: True
Explanation: Application Insights is designed to help you continuously improve performance and usability of your live application.
What type of applications can be monitored with Application Insights?
- A. Web applications
- B. Background components
- C. Azure Services
- D. Services hosted on-premises
- E. Mobile apps
Answer: A, B, C, D
Explanation: Application Insights can be used to monitor all the listed application types.
True or False: You need to redeploy your application after setting up Application Insights.
- Answer: False
Explanation: Application Insights can be configured without redeploying the application if you are using a supported language and integration.
In Azure Application Insights, what does the Availability feature enable you to do?
- A. Load balance your application.
- B. Monitor your application in real-time.
- C. Monitor the availability of your app.
- D. Check if a URL responds to a simple request.
Answer: C, D
Explanation: The Availability feature in Azure Application Insights enables you to test the availability of your app and check whether a URL responds to a request.
True or False: You can use Application Insights only with Azure hosted applications.
- Answer: False
Explanation: Application insights can be used not just with Azure hosted applications, but also with applications hosted on-premises, other clouds, and even offline applications.
What type of data can be captured with Application Insights?
- A. Availability data
- B. Request rates, response times, and failure rates
- C. Exceptions
- D. Dependencies
- E. Host diagnostics
Answer: A, B, C, D, E
Explanation: Application Insights is designed to help you detect and diagnose performance and availability issues, and all these data types support that objective.
True or False: Once data is sampled and ingested in Application Insights, original data can be retrieved.
- Answer: False
Explanation: The purpose of sampling is to reduce the volume of telemetry data sent to Application Insights. Once data is sampled and ingested, the original detailed data is no longer available.
What is the default data retention period of Application Insights?
- A. 30 days
- B. 60 days
- C. 90 days
- D. 120 days
Answer: C. 90 days
Explanation: The default retention period for Application Insights is 90 days, after which the data is automatically deleted.
True or False: In Azure Application Insights, you must manually install the SDK for each monitoring agent.
- Answer: False
Explanation: Some Azure services automatically integrate with Application Insights, without the need to manually install the SDK.
Can Application Insights be used to monitor Docker containers and Kubernetes?
- Answer: Yes
Explanation: Application Insights supports container monitoring, including Docker and Kubernetes.
True or False: Application Insights can collect data only from the server side.
- Answer: False
Explanation: Application Insights can collect data from server side as well as client side (e.g. page views, user and session counts).
Interview Questions
What is Application Insights in Microsoft Azure?
Application Insights is an extensible Application Performance Management (APM) service for application developers. You can use it to monitor your live applications.
Mention the steps to configure an app to use Application Insights in Azure?
The steps include: create an Application Insights resource in Azure, install the Application Insights SDK in your app, and configure your app to use the Application Insights resource using the Instrumentation Key.
What is the role of the Instrumentation Key in Application Insights?
Every Application Insights resource has an associated Instrumentation Key. This Key is used by the app to send telemetry data to the correct Application Insights resource.
How can you retrieve the Instrumentation Key for Application Insights in the Azure portal?
You can retrieve the Instrumentation Key from the overview page of your Application Insights resource in the Azure portal.
Can you configure multiple applications to send data to a single Application Insights resource?
Yes, you can do that by configuring each application with the same Instrumentation Key.
In which programming languages is Application Insights SDK available?
Application Insights SDK is available in several languages including .NET, Java, JavaScript, Node.js and Python.
How do you enable Application Insights during application development in Visual Studio?
This can be done by right-clicking on the project in the Solution Explorer, selecting “Add”, then “Application Insights Telemetry”.
What is the purpose of the Application Insights Connector?
The Azure Application Insights Connector efficiently pulls your data into Power BI, so you can better understand and analyze your data.
How can you view the telemetry data sent by your app to Application Insights?
The telemetry data can be viewed in the Azure portal in the Application Insights resource overview blade and other blades like Metrics, Performance, and Failure.
Can the data retention time be configured in Application Insights?
Yes, the data retention time can be configured. By default, the data is retained for 90 days.
How can you send custom events and metrics to Application Insights?
By using the TrackEvent and TrackMetric methods of the TelemetryClient object, you can send custom events and metrics.
How to configure the sampling in Application Insights?
Sampling in Application Insights can be configured in the application’s code or in the Application Insights portal. This feature allows you to control what percentage of the telemetry data gets sent to Application Insights.
How to filter the telemetry data in Application Insights?
You can use Telemetry Initializers and Telemetry Processors to filter and modify the telemetry data in Application Insights.
What’s the difference between standard and snapshot debugger logs in Application Insights?
Standard logs in Application Insights provide basic trace information, exception details, and request details. Snapshot debugger logs provide much more detailed debugging information, including local variables and the call stack.
Can Application Insights be used to monitor Azure Functions?
Yes, Application Insights can be used to monitor Azure Functions. It is integrated into Azure Functions and can be enabled during the creation of a function app.