All practice questions

26 questions

Question 1Question

A backend API running on Azure Container Instances writes diagnostic log traces to Application Insights. You need to verify if any error-level logs have been recorded recently. Which Kusto Query Language (KQL) keywords complete the query to retrieve all traces with a severity level of 3 that occurred within the last 2 hours?

Fill in the blanks below


| where timestamp >
(2h)
| where severityLevel == 3
Show answer & explanation

Answer

The correct KQL query begins with the table name 'traces' and utilizes the 'ago' function to filter for records from the last 2 hours.
The correct query targets the 'traces' table to retrieve diagnostic logs and applies a time filter using the 'ago' function to restrict results to the last 2 hours.

Step-by-Step Solution

1
Identify the correct telemetry table for log traces.
traces
Application Insights stores diagnostic log traces (such as those from standard logging frameworks) in the 'traces' table.
2
Identify the function used for relative time range filtering.
ago
The 'ago()' function is the standard KQL operator used to subtract a time span from the current UTC time.

Key Concept

Querying trace logs in Application Insights using Kusto Query Language (KQL)
Question 2Question

You are analyzing application performance issues in Azure Application Insights. You need to write a Kusto Query Language (KQL) query to retrieve the timestamp, name, and duration for all requests that took longer than 2 seconds (2000 milliseconds). How should you complete the KQL query?

Fill in the blanks below

requests
|
duration > 2000
|
timestamp, name, duration
Show answer & explanation

Answer

The query is completed by using the 'where' operator to filter records by duration, and the 'project' operator to select the specific columns for the output.
The correct operators are 'where' for filtering the records and 'project' for selecting the specific columns to output in the result.

Step-by-Step Solution

1
Identify the filtering operator to restrict records based on the duration value.
The 'where' operator is chosen to filter records where duration > 2000.
In KQL, 'where' is the correct operator for filtering rows based on a boolean condition.
2
Identify the projection operator to select the columns to return.
The 'project' operator is chosen to output 'timestamp', 'name', and 'duration'.
In KQL, 'project' is used to specify which columns should be included in the final result set.

Key Concept

Basic KQL querying structure using where and project operators for filtering and selecting data.
Question 3Question

A developer is investigating a performance bottleneck in an Azure Function App. They want to retrieve all dependency calls from the last 6 hours that took longer than the 90th percentile of all dependency durations during that same period. Complete the Kusto Query Language (KQL) query to retrieve these slow dependency calls by filling in the blanks.

Fill in the blanks below

kql
let threshold = toscalar(
dependencies
| where timestamp > ago(6h)
| summarize
(duration, 90)
);
dependencies
| where timestamp > ago(6h)
| where duration >

Show answer & explanation

Answer

Use 'percentile' or 'percentiles' in the first blank to compute the 90th percentile baseline, and use 'threshold' in the second blank to filter dependency durations against the computed scalar variable.
The query calculates the 90th percentile of dependency call durations over the last 6 hours using the `percentile` function. By using `toscalar()`, this single value is stored in the `threshold` variable. The main query then references `threshold` to filter for dependency records whose duration exceeds the computed value.

Step-by-Step Solution

1
Define the aggregation function to find the 90th percentile of dependency call durations.
The function `percentile(duration, 90)` is specified.
This determines the 90th percentile boundary value of the duration across all dependency records within the specified time range.
2
Assign the scalar value to a variable named threshold.
The `let threshold = toscalar(...)` expression assigns the scalar result.
Using `toscalar()` converts the single-value tabular result into a scalar type so it can be evaluated in subsequent filter comparisons.
3
Filter the primary dependencies table using the threshold variable.
The final filter statement evaluates `where duration > threshold`.
This isolates the dependency calls that took longer than the 90th percentile threshold limit.

Key Concept

Calculating percentiles and using scalar variables in Kusto Query Language (KQL) queries for telemetry analysis.
Estimated Time:1m 30s
Question 4Question

You are monitoring a high-volume Azure App Service web application using Azure Application Insights. You need to write an optimized Kusto Query Language (KQL) query to count the number of slow external HTTP dependency calls.

The query must meet the following requirements:
1. Dynamically calculate the 90th percentile duration of all HTTP dependencies over the last 24 hours and use this as a threshold.
2. Filter the `dependencies` table to include only HTTP calls whose duration exceeds this threshold.
3. Join the filtered dependencies with the `requests` table to associate them with their parent operations.
4. Group the results by the operation name (from the `requests` table) and the dependency target (from the `dependencies` table) to display the total count of slow dependency calls.
5. Apply time-range filters as early as possible to minimize the volume of data scanned and prevent query performance issues.

Complete the KQL query below by filling in the blanks with the correct KQL functions, table fields, or join operators.

Fill in the blanks below

let start = ago(24h);
let threshold =
(
dependencies
| where timestamp >= start
| where type == "Http"
| summarize percentile(duration, 90)
);
dependencies
| where
>= start
| where type == "Http" and duration > threshold
| join kind=
(
requests
| where
>= start
) on operation_Id
| summarize SlowCount = count() by RequestName = name, Target = target
Show answer & explanation

Answer

The query must evaluate the subquery as a scalar value using toscalar, filter both tables early using timestamp, and perform an inner (or innerunique) join to group by fields from both tables.
The correct query uses toscalar to dynamically retrieve a single numeric threshold for comparison, restricts the data scan on both tables using the timestamp column for optimization, and uses an inner join to correlate and preserve columns from both tables so they can be grouped by request name and dependency target.

Step-by-Step Solution

1
Wrap the threshold subquery with the correct KQL function.
Using the toscalar function converts the single-column, single-row table output of the subquery into a scalar value.
In KQL, comparing a scalar field like duration to a subquery's result using scalar operators (like >) requires the subquery to be explicitly evaluated as a scalar value.
2
Identify the performance-critical filtering field for the tables.
Using the timestamp column to restrict query execution to the last 24 hours.
Applying time-range filters using the timestamp field on both tables before joining prevents full-table scans of the historical telemetry store, which is critical for query efficiency and avoiding timeouts on high-volume workspaces.
3
Select the correct join operator that preserves the required schema.
Using the inner (or innerunique) join kind.
Since the final projection requires columns from both tables (name from requests and target from dependencies), a semi-join cannot be used. An inner join preserves and correlates the columns from both tables based on the operation_Id.

Key Concept

Writing optimized KQL queries that combine scalar subqueries, early time-range filtering, and appropriate schema-preserving joins to troubleshoot App Insights telemetry.
Question 5Question

An enterprise is migrating its legacy payment processing API to Azure API Management (APIM). To support blue-green deployments, the API gateway must route incoming requests dynamically based on a custom HTTP header named `X-Routing-Environment`. If the header value is `canary`, the gateway must route the request to a backend service registered with the ID `canary-endpoint`. Otherwise, the request should continue to the default backend.

Complete the following XML policy snippet to implement the dynamic routing logic. Fill in the blanks with the correct context variable and policy element name.

Fill in the blanks below

Complete the XML policy configuration below to dynamically route requests based on the header value:

xml
<policies>
<inbound>
<base />
<choose>
<when condition="@(
.Request.Headers.GetValueOrDefault("X-Routing-Environment") == "canary")">
<
backend-id="canary-endpoint" />
</when>
</choose>
</inbound>
</policies>
Show answer & explanation

Answer

The first blank must be filled with `context` and the second blank must be filled with `set-backend-service`.
The correct configuration uses the read-only C# context variable `context` to access the HTTP headers of the incoming request, and uses the `set-backend-service` policy to override the default backend with the registered backend service ID.

Step-by-Step Solution

1
Identify the C# context variable used within APIM policy expressions.
The `context` variable provides access to request headers and other contextual data.
The policy expression needs to read the incoming request header collection via `context.Request.Headers`.
2
Identify the policy element that redirects a request to a registered backend ID.
The `<set-backend-service>` policy element allows routing requests to a backend specified by its ID.
The requirement specifies routing the request to a backend service registered with the ID `canary-endpoint`, which is configured using `<set-backend-service backend-id="canary-endpoint" />`.

Key Concept

Dynamic backend routing using context variables and set-backend-service policies in Azure API Management.
Question 6Question

You are developing a batch telemetry processing service in C# that consumes messages from an Azure Queue Storage queue named telemetry-ingest. The service must retrieve up to 32 messages at a time and prevent other instances from processing these messages for 5 minutes while they are being processed. Once a message is successfully processed, it must be permanently removed from the queue. Complete the C# code snippet by filling in the blanks with the correct Azure Storage Queues SDK for .NET method names.

Fill in the blanks below

using System;
using System.Threading.Tasks;
using Azure.Storage.Queues;
using Azure.Storage.Queues.Models;

public async Task ProcessTelemetryBatchAsync(QueueClient queueClient)
{
var response = await queueClient.
(
maxMessages: 32,
visibilityTimeout: TimeSpan.FromMinutes(5)
);

foreach (var message in response.Value)
{
try
{
ProcessTelemetry(message.Body.ToString());

await queueClient.
(message.MessageId, message.PopReceipt);
}
catch (Exception ex)
{
// Log error
}
}
}
Show answer & explanation

Answer

The first blank must be filled with ReceiveMessagesAsync to retrieve multiple messages with a visibility timeout, and the second blank must be filled with DeleteMessageAsync to delete the processed message from the queue using its ID and pop receipt.
ReceiveMessagesAsync is the correct method in the Azure.Storage.Queues SDK to retrieve one or more messages and hide them from other consumers by setting a visibility timeout. DeleteMessageAsync is the correct method to remove a message from the queue after processing, requiring both the message ID and the pop receipt.

Step-by-Step Solution

1
Identify the method required to retrieve multiple messages asynchronously with custom parameters in Azure.Storage.Queues.
ReceiveMessagesAsync is identified as the method that accepts maxMessages and visibilityTimeout parameters and returns a Response containing an array of messages.
The scenario requires retrieving up to 32 messages at once and locking them (hiding them) for 5 minutes, which is done using ReceiveMessagesAsync.
2
Identify the method required to remove a message from the queue after processing is complete.
DeleteMessageAsync is identified as the method that takes a MessageId and PopReceipt to permanently delete the message.
Messages in Azure Storage Queues must be explicitly deleted after processing to prevent them from becoming visible again after the visibility timeout expires.

Key Concept

Retrieving and deleting queue messages using the Azure.Storage.Queues SDK for .NET
Estimated Time:2m 0s
Question 7Question

You are developing a worker utility in C# that processes queue messages. You need to configure Application Insights telemetry programmatically without using dependency injection. Complete the following C# code snippet to initialize the telemetry configuration and apply the connection string. What are the correct API members to write in the blanks?

Fill in the blanks below

TelemetryConfiguration config = TelemetryConfiguration.();
config.
= "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://eastus-0.in.applicationinsights.azure.com/";
TelemetryClient client = new TelemetryClient(config);
Show answer & explanation

Answer

Use 'CreateDefault' to instantiate the default configuration and 'ConnectionString' to set the Azure Monitor connection string.
To manually configure telemetry in C#, TelemetryConfiguration.CreateDefault() is invoked to create a configuration instance with default settings. The ConnectionString property is then assigned the connection string of the Application Insights resource. A TelemetryClient is subsequently initialized using this configuration.

Step-by-Step Solution

1
Identify the factory method on TelemetryConfiguration to instantiate the configuration.
TelemetryConfiguration.CreateDefault()
It returns a new TelemetryConfiguration instance pre-configured with standard telemetry initializers and channels.
2
Identify the property of TelemetryConfiguration that holds the ingestion parameters.
ConnectionString
The ConnectionString property replaced the deprecated InstrumentationKey property to route and authenticate telemetry data securely.

Key Concept

Manual initialization of Application Insights telemetry configuration in .NET applications
Question 8Question

An enterprise order processing application sends custom metric telemetry to Azure Application Insights to monitor message queue sizes. A custom metric named 'QueueBacklog' is recorded, and the specific queue's identifier is stored inside a custom dimension named 'QueueName'.

You need to write a Kusto Query Language (KQL) query to find the maximum backlog value for each queue over the last 36 hours. To ensure optimal query performance, you must filter by time range before performing any other operations.

How should you complete the KQL query?

Fill in the blanks below

kusto

| where timestamp > ago(36h) and name == "QueueBacklog"
| extend QueueName =
(customDimensions.QueueName)
| summarize MaxBacklog =
(value) by QueueName
Show answer & explanation

Answer

To complete the query, query the 'customMetrics' table first to load custom metric telemetry, then use the 'tostring' function to cast the dynamic custom dimension property to a string, and finally use the 'max' aggregation function to find the maximum backlog value.
The query starts by targeting the 'customMetrics' telemetry table. To ensure optimization, the time-range filter is applied immediately using the 'where' clause, which restricts processing to the last 36 hours. The dynamic property 'customDimensions.QueueName' is cast to a string type using the 'tostring' function. Finally, the 'max' aggregation function calculates the highest backlog value recorded in the 'value' column, grouping the results by the queue name.

Step-by-Step Solution

1
Select the correct table for custom metrics telemetry.
The query starts with the 'customMetrics' table name.
Application Insights stores custom metrics recorded via the TrackMetric API inside the 'customMetrics' table.
2
Cast the custom dimension to a string format.
Apply the 'tostring' function to 'customDimensions.QueueName'.
Properties in the 'customDimensions' property bag are dynamic objects. To group by them in KQL summarization, they must be cast to string types using 'tostring()'.
3
Aggregate the maximum metric value.
Use the 'max' aggregation function on the 'value' column.
The 'max' function calculates the highest value recorded for the 'value' field in the 'customMetrics' table across the specified time frame.

Key Concept

Querying custom metrics and dimensions in Application Insights using optimized KQL filters and aggregations.
Estimated Time:2m 0s
Question 9Question

Complete the statement to identify the XML element required to inherit and execute policies from a parent scope in Azure API Management.

Fill in the blanks below

In Azure API Management, parent policies are not inherited by default at lower scopes. To inherit and execute policies defined at a higher scope within a specific policy section, you must include the XML element inside that section.
Show answer & explanation

Answer

The base element (or <base />)
The base element (often written as <base />) is used in Azure API Management policies to inherit and execute policies configured at a higher scope (such as Product or Global) inside the current scope (such as API or Operation). Its placement determines whether the current scope's policies run before or after the parent scope's policies.

Step-by-Step Solution

1
Identify the mechanism in Azure API Management policies that controls policy inheritance.
Policies are evaluated hierarchically (Global -> Product -> API -> Operation).
To avoid overriding parent policies, APIM uses a specific element to reference parent-level rules.
2
Determine the correct XML element for this mechanism.
The <base /> element represents the execution of policies from the parent scope.
Including <base /> tells the gateway to run the inherited policies at that exact point in the execution pipeline.

Key Concept

API Management policy inheritance and scoping
Estimated Time:45s
Question 10Question

You are configuring an inbound policy in Azure API Management to modify the request path before it is forwarded to the backend service. The policy must redirect the client request from the public URL structure to the backend endpoint path /users/{id}. Complete the policy XML block by identifying the missing element name to rewrite the path:

Fill in the blanks below

<inbound>
<base />
<
template="/users/{id}" />
</inbound>
Show answer & explanation

Answer

rewrite-uri
The rewrite-uri policy modifies a request URL from the form in which it was received to the form expected by the web service that implements the API. In this scenario, it is used to redirect incoming requests to the /users/{id} path template.

Step-by-Step Solution

1
Identify the requirement to modify the request path/URL before forwarding to the backend.
The requirement is to rewrite the request URL/path to match the backend path structure.
Azure API Management provides specific inbound policies to transform request paths.
2
Select the appropriate policy element for rewriting URLs.
The rewrite-uri policy is the correct element used to change a request URL path from its public form to the form expected by the backend service.
This policy modifies the request path directly inside the inbound section using the template attribute.

Key Concept

Azure API Management URL rewriting policy
Question 11Question

You are configuring Application Insights telemetry in a C# console application. You need to enrich all telemetry sent to Application Insights with a custom cloud role name by implementing and registering a telemetry initializer.

Complete the code snippet by identifying the correct types and properties for each blank.

Fill in the blanks below

using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;

// A custom initializer to enrich all telemetry with cloud role details
public class CloudRoleNameInitializer :

{
public void Initialize(
telemetry)
{
telemetry.Context.Cloud.RoleName = "OrderProcessingService";
}
}

// In the application startup code:
var config = TelemetryConfiguration.CreateDefault();
config.ConnectionString = "ConnectionStringValue";
config.
.Add(new CloudRoleNameInitializer());
Show answer & explanation

Answer

Blank 1 should be filled with ITelemetryInitializer, Blank 2 with ITelemetry, and Blank 3 with TelemetryInitializers.
To write a custom telemetry initializer, you must implement the ITelemetryInitializer interface, which has a single Initialize method taking an ITelemetry argument. To run it, you must add it to the TelemetryInitializers collection on the active TelemetryConfiguration.

Step-by-Step Solution

1
Implement the telemetry initializer interface.
The class must implement the ITelemetryInitializer interface to hook into the Application Insights telemetry pipeline.
The Application Insights SDK uses this interface to identify custom initializers.
2
Define the input parameter type for the Initialize method.
The method signature must accept an ITelemetry object.
This object represents the raw telemetry data being processed and exposes the Context property to allow modification of metadata like Cloud Role Name.
3
Register the initializer instance in the active configuration.
Add the custom initializer to the TelemetryInitializers collection on the configuration object.
This ensures the SDK executes the initializer for all generated telemetry data before transmission.

Key Concept

Programmatic configuration of Application Insights Telemetry Initializers in C#
Estimated Time:2m 0s
Question 12Question

An operations engineer needs to implement a message consumer in C# for Azure Queue Storage using the modern Azure.Storage.Queues SDK. The consumer must acquire a message, process it, and then immediately delete it from the queue.

Complete the C# code snippet below by filling in the blanks. What are the correct asynchronous method names to retrieve and delete the message?

Fill in the blanks below

csharp
QueueClient queueClient = new QueueClient(connectionString, "work-items");

// Retrieve the message
QueueMessage[] messages = await queueClient.
(maxMessages: 1);

if (messages.Length > 0)
{
QueueMessage message = messages[0];

// Process the message...

// Permanently remove the message from the queue
await queueClient.
(message.MessageId, message.PopReceipt);
}
Show answer & explanation

Answer

The message must be retrieved using the ReceiveMessagesAsync method, and then permanently deleted from the queue using the DeleteMessageAsync method.
The ReceiveMessagesAsync method retrieves one or more messages and makes them invisible to other processors. It provides the PopReceipt which, along with the MessageId, must be passed to DeleteMessageAsync to successfully remove the message from the queue.

Step-by-Step Solution

1
Identify the method required to pull a message from the queue and mark it as invisible to other consumers.
ReceiveMessagesAsync is the standard asynchronous method to retrieve messages.
This method hides the message for a default visibility timeout and returns a PopReceipt required for later deletion.
2
Identify the method required to permanently delete the message once processing is complete.
DeleteMessageAsync removes the message using its ID and PopReceipt.
Explicitly deleting the message ensures it does not return to the queue when the visibility timeout expires.

Key Concept

Retrieving and deleting messages using the Azure.Storage.Queues SDK
Estimated Time:1m 0s
Question 13Question

You are configuring an inbound policy for an Azure API Management (APIM) instance. You need to route incoming API requests to a specific regional backend API based on the value of a custom header named `X-Region`. If the header value is `EU`, the request must be routed to `https://eu-backend.contoso.com/api`. Otherwise, the request must use the default backend. What are the correct API Management policy element names required to complete the XML configuration below?

Fill in the blanks below

xml
<inbound>
<base />
<choose>
<
condition="@(context.Request.Headers.GetValueOrDefault("X-Region") == "EU")">
<
base-url="https://eu-backend.contoso.com/api" />
</
>
</choose>
</inbound>
Show answer & explanation

Answer

The correct policy elements are 'when' to evaluate the conditional routing expression and 'set-backend-service' to redirect the backend API base URL.
The correct elements are 'when' and 'set-backend-service'. The `<when>` element defines a conditional branch inside the `<choose>` parent element. The `<set-backend-service>` element alters the destination endpoint for the incoming API request during the inbound processing pipeline.

Step-by-Step Solution

1
Identify the conditional block element within the `<choose>` policy structure.
The `<choose>` element executes policies in the first nested `<when>` element whose condition evaluates to true.
To evaluate whether the custom header `X-Region` is equal to `EU`, a conditional `<when>` block must be declared.
2
Identify the policy element required to alter the destination URL for the backend API.
The `<set-backend-service>` policy dynamically changes the destination backend base URL for the request.
To route requests to the regional URL when the condition is met, the `<set-backend-service>` policy with the `base-url` attribute must be placed inside the conditional block.

Key Concept

Configuring conditional routing policies in Azure API Management using the choose-when policy structure and the set-backend-service policy element.
Estimated Time:1m 30s
Question 14Question

Complete the Azure API Management (APIM) policy snippet to append or replace a query parameter in the backend request with the client's subscription ID.

Fill in the blanks below

You are configuring an inbound policy for an Azure API Management gateway. You need to ensure that a query parameter named `client-id` is sent to the backend service. If the `client-id` query parameter already exists in the incoming request, it must be overwritten with the subscription ID from the request context.

Complete the XML policy configuration by filling in the blanks.

xml
<inbound>
<base />
<
name="client-id" exists-action="">
<value>@(context.Subscription.Id)</value>
</
>
</inbound>
Show answer & explanation

Answer

blank_1 = set-query-parameter, blank_2 = override
The `<set-query-parameter>` policy adds, replaces, or deletes query parameters in the request sent to the backend. Setting the `exists-action` attribute to `override` ensures that any existing query parameter with the same name is replaced by the subscription ID from the request context.

Step-by-Step Solution

1
Identify the policy element that modifies query parameters in API Management.
The correct element is `<set-query-parameter>`.
This policy is specifically designed to add, replace, or delete query parameters.
2
Determine the correct value for the `exists-action` attribute to overwrite an existing query parameter.
The correct attribute value is `override`.
The `override` action ensures that if the query parameter is already present, its value will be replaced.

Key Concept

API Management policies can manipulate incoming requests to backends. The `<set-query-parameter>` policy modifies request query strings, and setting `exists-action` to `override` replaces any pre-existing query parameter value.
Question 15Question

You are developing a .NET 8 background worker service that processes queue messages and communicates with an external database. You need to manually track the database call as a dependency using the Application Insights SDK, and ensure any thrown exceptions are logged to Application Insights.

Complete the code by filling in the blanks with the correct TelemetryClient method names.

Fill in the blanks below

using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using System;
using System.Threading.Tasks;

public class QueueProcessor
{
private readonly TelemetryClient _telemetryClient;
private readonly IExternalService _externalService;

public QueueProcessor(TelemetryClient telemetryClient, IExternalService externalService)
{
_telemetryClient = telemetryClient;
_externalService = externalService;
}

public async Task ProcessJobAsync(string jobId)
{
// Start and correlate a dependency tracking operation
using (var operation = _telemetryClient.
<DependencyTelemetry>("DatabaseCall"))
{
try
{
await _externalService.ExecuteAsync(jobId);
operation.Telemetry.Success = true;
}
catch (Exception ex)
{
operation.Telemetry.Success = false;
_telemetryClient.
(ex);
throw;
}
}
}
}
Show answer & explanation

Answer

The first blank must be 'StartOperation' to begin a correlated telemetry tracking operation, and the second blank must be 'TrackException' to record the exception details in Application Insights.
The correct method for starting a scoped operation telemetry flow is `StartOperation`, which integrates seamlessly with C#'s `using` pattern to capture telemetry duration. The correct method for recording raw application exceptions is `TrackException` to capture the complete error signature.

Step-by-Step Solution

1
Identify the telemetry tracking pattern designed to measure operation duration and context propagation using C# using-blocks.
The `StartOperation` extension method of `TelemetryClient` starts a timed operation scope and returns an `IOperationHolder<T>` instance.
Using `StartOperation` automatically sets start time, tracks duration upon disposal, and correlates sub-operations.
2
Determine the correct telemetry API method to log exceptions with full call stack details.
The `TrackException` method accepts an `Exception` object to send to the Application Insights exception log store.
Using `TrackException` maps the caught error to Azure Monitor exception tables, ensuring diagnostic details are preserved.

Key Concept

Manual dependency tracking and exception instrumentation with Application Insights SDK
Question 16Question

You are developing a solution that uses Azure API Management (APIM). You need to configure an inbound policy that forwards the client's original IP address to the backend service by adding a custom request header named `X-Client-IP`. You must use a C# policy expression within the `<set-header>` policy.

Complete the policy configuration by filling in the missing C# expression in the blank. What is the C# expression to retrieve the client's IP address from the request context?

Fill in the blanks below

<inbound>
<base />
<set-header name="X-Client-IP" exists-action="override">
<value>@(
)</value>
</set-header>
</inbound>
Show answer & explanation

Answer

context.Request.IpAddress
In Azure API Management, the context object is a read-only variable available within policy expressions. To access details about the client's request, you use the Request property of the context. The client's IP address is specifically exposed via the IpAddress property on the Request object. Therefore, the correct expression to fill the blank is context.Request.IpAddress.

Step-by-Step Solution

1
Identify the context variable available in Azure API Management policy expressions.
The context variable is implicitly available in all APIM policy expressions.
Policy expressions are C# statements or expressions that have access to the context variable.
2
Determine the property of the context variable that represents the incoming HTTP request.
The context.Request property represents the incoming request sent by the client.
To retrieve information about the incoming client call (like headers, query parameters, or IP address), we must inspect the request context.
3
Locate the specific property containing the client's IP address on the Request object.
context.Request.IpAddress returns the IP address of the client as a string.
This property is populated by the API Management gateway with the caller's IP address.

Key Concept

Azure API Management context variables and policy expressions
Question 17Question

You are developing an ASP.NET Core Web API with the Application Insights SDK. To optimize resource consumption in a containerized environment, you must programmatically disable the collection of performance counters and disable adaptive sampling. Complete the code snippet by filling in the correct properties of the ApplicationInsightsServiceOptions class.

Fill in the blanks below

csharp
builder.Services.AddApplicationInsightsTelemetry(options =>
{
options.ConnectionString = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
options.
= false; // Disables performance counter collection
options.
= false; // Disables adaptive sampling
});
Show answer & explanation

Answer

To programmatically disable performance counter collection, set the EnablePerformanceCounterCollectionModule property to false. To disable adaptive sampling, set the EnableAdaptiveSampling property to false.
The correct properties are EnablePerformanceCounterCollectionModule to toggle the OS performance counter collection module and EnableAdaptiveSampling to control the sampling logic applied to outbound telemetry data.

Step-by-Step Solution

1
Locate the configuration options class used by the Application Insights SDK in ASP.NET Core.
ApplicationInsightsServiceOptions is passed to the AddApplicationInsightsTelemetry extension method configuration lambda.
This class holds the properties to configure the default telemetry modules and telemetry collection behaviors.
2
Find the boolean property responsible for loading the PerformanceCollectorModule.
EnablePerformanceCounterCollectionModule
Setting this property to false stops the SDK from spinning up the module that collects CPU, memory, and garbage collection metrics from the host operating system.
3
Find the boolean property that controls adaptive sampling.
EnableAdaptiveSampling
Setting this property to false disables adaptive sampling, which ensures 100% of telemetry data is transmitted rather than being dynamically sampled.

Key Concept

Configuring default telemetry modules and behavior using ApplicationInsightsServiceOptions in ASP.NET Core.
Question 18Question

An enterprise application uses Azure API Management (APIM). You need to configure an inbound policy that evaluates the 'X-Client-Type' request header. If the header value is 'Internal', the request must route to an internal backend service. Otherwise, it should route to the default backend service. Which XML element names must be used to complete the conditional logic in the policy snippet?

Fill in the blanks below

xml
<inbound>
<base />
<
>
<
condition="@(context.Request.Headers.GetValueOrDefault('X-Client-Type') == 'Internal')">
<set-backend-service base-url="https://internal-api.service.local" />
</
>
</
>
</inbound>
Show answer & explanation

Answer

blank_1: choose, blank_2: when
The choose element evaluates nested when elements sequentially from top to bottom. The first when element with a condition that evaluates to true is applied. This conditional routing structure allows policies to dynamically change backend targets or execute specific operations based on headers.

Step-by-Step Solution

1
Identify the policy structure needed for conditional execution.
The choose block is the correct control-flow policy in Azure API Management.
Azure API Management uses the <choose> element to act as a switch-case statement for evaluating conditions sequentially.
2
Determine the conditional branch element.
The <when> element represents a specific condition to evaluate.
Inside a <choose> element, one or more <when> elements must be defined to evaluate expressions and run nested policies if true.

Key Concept

Conditional policy execution in Azure API Management
Estimated Time:1m 30s
Question 19Question

Complete the C# code below to define a custom telemetry processor that filters out successful dependency telemetry and register it within the ASP.NET Core dependency injection container.

Fill in the blanks below

public class DependencyFilter :
{
private ITelemetryProcessor Next { get; set; }

public DependencyFilter(ITelemetryProcessor next)
{
this.Next = next;
}

public void Process(ITelemetry item)
{
if (item is DependencyTelemetry dependency && dependency.Success == true)
{
return; // Filter out
}
this.Next.Process(item);
}
}

// In Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApplicationInsightsTelemetry();
builder.Services.
<DependencyFilter>();
Show answer & explanation

Answer

Implement the ITelemetryProcessor interface for the filter class, and register the class in the ServiceCollection using the AddApplicationInsightsTelemetryProcessor extension method.
To create a custom telemetry filter, the class must implement ITelemetryProcessor and its Process method. To register it in an ASP.NET Core application, use the AddApplicationInsightsTelemetryProcessor service extension method. This registers the processor so it is executed for every telemetry item passing through the telemetry pipeline.

Step-by-Step Solution

1
Identify the interface required to implement a custom telemetry filtering mechanism in Application Insights.
The correct interface is ITelemetryProcessor, which defines the Process method.
ITelemetryProcessor is the standard interface in the Application Insights SDK for custom telemetry filters that run in the telemetry pipeline.
2
Identify the service collection extension method used to register the custom telemetry processor.
The correct extension method is AddApplicationInsightsTelemetryProcessor.
This method ensures that the telemetry processor is correctly integrated into the Application Insights pipeline along with dependency injection dependencies.

Key Concept

Custom Telemetry Filtering using ITelemetryProcessor and AddApplicationInsightsTelemetryProcessor in ASP.NET Core
Question 20Question

You are developing an audit utility in C# that processes messages in an Azure Queue Storage queue named inventory-audit. The utility must read the content of up to 10 messages to log their metadata, but it must not lock the messages or make them invisible to other processing services. You are using the Azure.Storage.Queues SDK. Complete the code snippet below using explicit typing (do not use var) to retrieve the messages. Which code segments should you use to fill in the blanks?

Fill in the blanks below

QueueClient queueClient = new QueueClient(connectionString, "inventory-audit");

// Inspect up to 10 messages without changing their visibility
[] messages = (await queueClient.(maxMessages: 10)).Value;
Show answer & explanation

Answer

Use PeekedMessage for the array type in the first blank, and PeekMessagesAsync (or PeekMessages) for the queue client method in the second blank.
To inspect queue messages without acquiring a lease or modifying their visibility timeout, you must use the PeekMessagesAsync (or PeekMessages) method. This method returns a list of PeekedMessage objects, which represents the state of peeked messages (without pop receipt properties).

Step-by-Step Solution

1
Determine the message retrieval requirement.
The utility needs to read messages without locking them or making them invisible to other consumers.
This requirement indicates that a peek operation must be used instead of a standard receive operation.
2
Select the correct SDK method.
The Azure.Storage.Queues SDK provides the PeekMessagesAsync method (or synchronous PeekMessages) to read messages without modifying their visibility timeout.
ReceiveMessagesAsync would retrieve the messages and set a visibility timeout, locking them from other consumers.
3
Select the correct return type.
The PeekMessagesAsync method returns a collection of PeekedMessage objects rather than QueueMessage objects.
PeekedMessage represents messages that have been peeked and do not contain lease-specific properties like a PopReceipt.

Key Concept

Reading Azure Queue Storage messages without changing visibility (peeking)
Page 1 / 2Next
All practice questions — Microsoft Azure Developer (AZ-204) | Examkin