Tüm alıştırma soruları
972 soru
You are developing a .NET console application that processes payment transaction messages from an Azure Service Bus queue named `payments`. The application must retrieve messages one by one. To prevent transaction loss, messages must remain in the queue if processing fails or if the application crashes, and must be permanently removed only after successful processing. Which code snippet should you use to implement this message processing logic?
ServiceBusReceiver receiver = client.CreateReceiver("payments", new ServiceBusReceiverOptions
{
ReceiveMode = ServiceBusReceiveMode.PeekLock
});
ServiceBusReceivedMessage message = await receiver.ReceiveMessageAsync();
if (message != null)
{
try
{
await ProcessPaymentAsync(message);
await receiver.CompleteMessageAsync(message);
}
catch (Exception)
{
await receiver.AbandonMessageAsync(message);
}
}
ServiceBusReceiver receiver = client.CreateReceiver("payments", new ServiceBusReceiverOptions
{
ReceiveMode = ServiceBusReceiveMode.ReceiveAndDelete
});
ServiceBusReceivedMessage message = await receiver.ReceiveMessageAsync();
if (message != null)
{
try
{
await ProcessPaymentAsync(message);
await receiver.CompleteMessageAsync(message);
}
catch (Exception)
{
await receiver.AbandonMessageAsync(message);
}
}
ServiceBusReceiver receiver = client.CreateReceiver("payments", new ServiceBusReceiverOptions
{
ReceiveMode = ServiceBusReceiveMode.PeekLock
});
ServiceBusReceivedMessage message = await receiver.ReceiveMessageAsync();
if (message != null)
{
await ProcessPaymentAsync(message);
}
ServiceBusReceiver receiver = client.CreateReceiver("payments", new ServiceBusReceiverOptions
{
ReceiveMode = ServiceBusReceiveMode.ReceiveAndDelete
});
ServiceBusReceivedMessage message = await receiver.ReceiveMessageAsync();
if (message != null)
{
await ProcessPaymentAsync(message);
}
A C# background service runs on an Azure Virtual Machine that is configured with a user-assigned managed identity. The service must decrypt sensitive application data using an asymmetric key named `app-decrypt-key` stored in an Azure Key Vault named `contoso-vault`. The Key Vault has Azure role-based access control (Azure RBAC) enabled as its authorization model. You need to grant the minimum necessary permissions to the managed identity and implement the decryption logic in the service's C# code using the Azure SDK for .NET. Which two actions should you perform? (Choose two.)
Geçerli olan tümünü seçin
A team is migrating an on-premises web application to a C# .NET 8 Minimal API hosted on Azure Kubernetes Service (AKS). The containerized application includes the `Microsoft.ApplicationInsights.AspNetCore` package.
In the `Program.cs` file, the team registers telemetry using the following code:
csharp
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApplicationInsightsTelemetry();
During testing in the AKS cluster, the team notices that no telemetry data is populated in the Azure Portal, although the application starts up and processes HTTP requests without any exceptions. The Kubernetes deployment manifest currently defines only the `APPINSIGHTS_INSTRUMENTATIONKEY` environment variable.
Which action must the team take to ensure telemetry is sent successfully?
You are developing a C# service that processes inventory updates from a session-enabled Azure Service Bus queue named `inventory-queue`. The system must process updates for each store in strict chronological order. You need to implement the message retrieval and processing logic using the Azure.Messaging.ServiceBus SDK. Which sequence of actions must you perform to safely retrieve, process, and complete messages for a store session before releasing the session lock?
Öğeleri doğru sıraya koymak için sürükleyin
You are developing a command-line interface (CLI) tool in C# that developers will run on Linux servers without a graphical user interface (GUI). The CLI tool must authenticate users against Microsoft Entra ID to access a secure downstream API on their behalf. You need to configure the Microsoft Entra ID application registration and implement the token acquisition logic in the C# code. Which two actions should you perform? (Select two.)
Geçerli olan tümünü seçin
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.
Aşağıdaki boşlukları doldurun
builder.Services.AddApplicationInsightsTelemetry(options =>
{
options.ConnectionString = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
options. = false; // Disables performance counter collection
options. = false; // Disables adaptive sampling
});
A company hosts a legacy REST service behind an Azure API Management (APIM) instance. To prepare the service for migration, you must configure APIM policies to meet the following requirements:
- Remove the '/api/v1' path prefix from all incoming request URLs before forwarding them to the backend service.
- Limit clients to a maximum rate of 500 requests per 60 seconds per subscription.
Which two of the following policy fragments should you add to the <inbound> section of the policy XML file to satisfy these requirements? (Choose two.)
Geçerli olan tümünü seçin
A developer deploys a C# API to an Azure App Service named api-prod. The API retrieves its database password from an Azure Key Vault named kv-prod. The Key Vault's permission model is configured to use Azure role-based access control (Azure RBAC).
To configure the App Service, the developer creates an application setting named DbPassword with the following value:
@Microsoft.KeyVault(SecretUri=https://kv-prod.vault.azure.net/secrets/DbPassword)
After enabling the system-assigned managed identity on api-prod, the developer observes that the API receives a 403 Forbidden error when trying to retrieve the secret.
Which of the following actions should you perform to resolve the secret retrieval failure?
A logistics company implements a package dispatch system using an Azure Service Bus queue named `dispatch-queue`. You are writing a C# console application using the `Azure.Messaging.ServiceBus` SDK to process dispatch jobs. The application must guarantee that a dispatch job is only removed from the queue after it is successfully processed and saved to the database. If a database timeout or application crash occurs during processing, the message must become available for other receiver instances after the lock expires.
Which approach should you implement in your C# application to meet these requirements?
You are troubleshooting an Azure API Management (APIM) instance. A backend API requires an API key, which is stored in Azure Key Vault. You have created an APIM named value named `BackendApiKey` that references the Key Vault secret using the APIM instance's system-assigned managed identity.
You apply the following policy to the inbound section of the API:
xml
<inbound>
<base />
<set-header name="X-Api-Key" exists-action="override">
<value>{{BackendApiKey}}</value>
</set-header>
</inbound>
When clients call the API, they receive an HTTP 500 Internal Server Error. The APIM trace logs show that the named value `BackendApiKey` could not be resolved from Key Vault.
Which of the following is the most likely cause of this error?
You are developing a C# desktop application that will run on employee workstations. The application needs to retrieve user-specific records from an Azure SQL Database. You want to authenticate users via the Microsoft Identity Platform and access the database using the signed-in user's identity. Which authentication configuration should you implement?
You are developing a C# .NET 8 worker service hosted on Azure Container Apps. The service processes queue messages and is configured to send telemetry to Application Insights.
In Program.cs, you register the telemetry services:
csharp
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddApplicationInsightsTelemetryWorkerService(options =>
{
options.ConnectionString = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
});
Within a separate processor class, you instantiate the telemetry client manually to log custom events:
csharp
public class QueueProcessor
{
private static readonly TelemetryClient telemetryClient = new TelemetryClient();
public void ProcessMessage(string message)
{
// Processing logic
telemetryClient.TrackEvent("MessageProcessed");
}
}
During testing, you observe that standard system metrics and dependency telemetry are successfully recorded in Application Insights, but the custom MessageProcessed events are missing.
Which of the following describes the root cause of this behavior?
You are developing a secure C# web API that retrieves a database credential secret from Azure Key Vault. You need to automate the rotation of this secret using Azure Event Grid and a custom Azure Function. Which sequence of steps should you perform to configure the automated rotation?
Öğeleri doğru sıraya koymak için sürükleyin
An offline data processing utility is written in C# and runs on an Azure Linux VM. You configure telemetry by writing the following code block to log lifecycle events:
csharp
var configuration = new TelemetryConfiguration();
var client = new TelemetryClient(configuration);
client.TrackEvent("JobStarted");
During testing, you notice that no events are captured in the Application Insights logs. You must update the code to ensure telemetry is transmitted correctly.
Which TWO actions should you take to resolve this issue? (Select TWO.)
Geçerli olan tümünü seçin
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?
Aşağıdaki boşlukları doldurun
<inbound>
<base />
<>
< condition="@(context.Request.Headers.GetValueOrDefault('X-Client-Type') == 'Internal')">
<set-backend-service base-url="https://internal-api.service.local" />
</>
</>
</inbound>
You are developing a C# background daemon service that will run on an on-premises server. The service must periodically authenticate to the Microsoft Identity Platform without user interaction and retrieve files from a protected web API. You decide to use a client certificate stored in Azure Key Vault for authentication. The daemon service has an application registration in Microsoft Entra ID. Which two actions must you perform to configure the authentication flow and permissions? (Select two.)
Geçerli olan tümünü seçin
You are developing a .NET background worker application that processes messages from an Azure Service Bus queue named sensor-telemetry using the Azure.Messaging.ServiceBus SDK. The messages contain environmental data that must be successfully saved to an external SQL database. If the database is offline, the message must not be lost and must remain in the queue to be retried later. Which approach should you use to receive and process the messages?
An organization hosts a backend service that mandates mutual TLS (mTLS) authentication. You register the backend service in Azure API Management (APIM). You upload the client certificate to the APIM instance and want to configure the APIM gateway to present this certificate to the backend service when routing requests. Which policy configuration must you apply to meet this requirement?
You are developing a .NET 8 console application that will run as a WebJob on a Linux Azure App Service. The application must track custom operational metrics by using the Application Insights SDK.
You write the following code to initialize the telemetry tracking:
csharp
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
class Program
{
static void Main(string[] args)
{
var config = TelemetryConfiguration.CreateDefault();
var client = new TelemetryClient(config);
client.TrackEvent("WebJobStarted");
client.Flush();
}
}
When you run the WebJob, the application executes without throwing any exceptions, but no custom events are visible in your Application Insights resource.
Which of the following changes must you make to ensure that the telemetry data is sent successfully to Azure Monitor?
You are developing a C# console application that processes FIFO (first-in, first-out) messages from a session-enabled Azure Service Bus queue. The application must guarantee that messages in a session are processed in order and that the session lock is released only after all processing is complete.
Arrange the steps in the correct order to implement this message processing workflow using the Azure.Messaging.ServiceBus SDK.
Öğeleri doğru sıraya koymak için sürükleyin