Answer is A or C. However, the answer in this case is A, since the question didn't specify application type or runtime stack. It wouldn't make sense to configure startup.cs for a NodeJS app for example
To configure Application Insights for your application, the most common and recommended approach is to specify the Instrumentation Key in the appsettings.json file, which is used by the app to send telemetry data to the Application Insights instance.
In modern .NET Core applications, Startup.cs is used to configure services and middleware, including Application Insights. However, the actual connection string or instrumentation key for Application Insights should not be hardcoded directly in Startup.cs. Instead, it is best practice to store such configuration values in external configuration files like appsettings.json or environment variables for flexibility and security.
In Startup.cs, the Application Insights configuration typically reads values from the configuration system (e.g., appsettings.json). So the correct answer is A.
Example configuration in startup.cs:
csharpCopypublic void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
}
Therefore, option C (startup.cs) is the correct answer as it's the appropriate file for configuring Application Insights integration.
After further review, I am concluding that it's startup.cs. The key word is 'configure'.
Both appsettings.json and startup.cs files are involved in the process of setting up Application Insights for your app, but Startup.cs is where you actually configure the application to use Application Insights.
The appsettings.json file holds the Instrumentation Key that you use to connect to your Application Insights instance (AI1). So, while you do configure the app in Startup.cs, you often retrieve the necessary values (like the instrumentation key) from appsettings.json.
From ChatGPT:
While the Startup.cs file is used to configure services like Application Insights, you usually need to specify the instrumentation key in the appsettings.json, and then in the Startup.cs file, you enable Application Insights with the key from appsettings.json.
I think it is A, since it does not say anything about if it is a normal or core application, then i assume it is a normal.
First, you modify appsettings.json to store the key in a centralized location, which will be easier to change and secure.
Then, you use Startup.cs to wire up Application Insights by reading the key and configuring telemetry collection in the application.
you enable application insight by adding code to the startup.cs but you actually point to the AI1 by adding either a instrumentation key or a connection string. and the right place for such config is in appsettings.json
https://learn.microsoft.com/en-us/azure/azure-monitor/app/tutorial-asp-net-core
Enable Application Insights server-side telemetry
The Application Insights for ASP.NET Core web applications NuGet package encapsulates features to enable sending server-side telemetry to the Application Insights resource in Azure.
From the Visual Studio Solution Explorer, open the Program.cs file.
Screenshot of the Visual Studio Solution Explorer with the Program.cs file highlighted.
As addition, look at the comment of user renzoku below
C:
Regardless of the application and runtime used, to configure Application Insights in an application, it is usually necessary to modify the startup.cs file. This file is commonly used to configure the request pipeline and configure initial application settings, including configuring Application Insights to send telemetry data.
startup.cs
Configure it to establish the connection between Application Insights services with your .NET core app, enabling send telemetry data.
appsettings.json
Contains configuration for Application Insights.
for .net framework based web application, its AppSettings.json
for .net core based web application, its Startup.cs file.
Question does not talk about which .net application it is.
ChatGPT answer:
C. startup.cs
In a typical .NET application, such as App1, the startup.cs file contains the configuration and initialization code for the application. This file is responsible for configuring various services and middleware during the application's startup.
To enable and configure Application Insights, you would modify the startup.cs file and add the necessary code to set up Application Insights for your app. This typically involves adding services and configuring the Application Insights instrumentation key, which connects your app to the AI1 instance.
This section is not available anymore. Please use the main Exam Page.AZ-400 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
xRiot007
Highly Voted 1 year, 9 months agoRabi3
Most Recent 2 weeks, 6 days agoMousavi
3 months agonikolayivanov
3 months, 2 weeks agoPravinDhote
4 months, 2 weeks agoDankho
5 months agoDankho
5 months agoGooldmember
5 months, 3 weeks agoahmedmnassri
6 months, 4 weeks agoozbonny
1 year, 2 months agoRod_DA
1 year, 7 months agoyana_b
1 year, 8 months agoflafernan
1 year, 9 months agorenzoku
1 year, 9 months agonotsure1111
1 year, 10 months agoCervezerg
1 year, 10 months agod33ma
1 year, 10 months ago