Soru

Zorluk: ZorConfigure Application Insights Web Tests and Availability Monitoring

You are designing a monitoring solution for a critical REST API hosted behind Azure API Management (APIM). The backend service dynamically adds a custom response header named `X-Backend-Server` to indicate which server instance processed the request. The monitoring solution must meet the following requirements:

1. Send an HTTP POST request to `https://api.contoso.com/health` with a JSON payload of `{"ping": true}` every 5 minutes.
2. Verify that the response status code is 200.
3. Verify that the response contains the `X-Backend-Server` header to ensure routing is functioning correctly.
4. Report the test duration, location, and success status as availability metrics to Application Insights.

You need to implement the availability monitoring solution. Which of the following should you do?

  1. Deploy an Azure Function integrated with your virtual network. In the function code, execute the HTTP POST request, verify the response status code and the `X-Backend-Server` header, and report the results using `TelemetryClient.TrackAvailability()` with an `AvailabilityTelemetry` object. Configure the function app to retrieve the Application Insights connection string from Azure Key Vault using a system-assigned managed identity granted the Key Vault Secrets User role.Cevap
  2. B
    Configure a Standard availability test in Application Insights. To validate the response header, add a `<return-response>` policy to the `<inbound>` section of the API Management policy definition to copy the `X-Backend-Server` header value to the response body, and configure the test's Content Match success criteria to verify this value.
  3. C
    Deploy an Azure Function integrated with your virtual network to run the HTTP POST request and verify the response headers. In the function code, report the results using `TelemetryClient.TrackAvailability()`. Configure the function app to retrieve the Application Insights connection string from Azure Key Vault using a system-assigned managed identity, and grant the identity the Key Vault Contributor role on the Key Vault.
  4. D
    Deploy an Azure Function integrated with your virtual network to run the HTTP POST request and verify the response headers. In the function code, report the results by instantiating the `TelemetryClient` using the parameterless constructor `new TelemetryClient()` without configuring the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable or passing any configuration objects to the client.

Cevap

Deploy an Azure Function integrated with the virtual network that executes the POST request, validates the header, and calls TrackAvailability() with a managed identity configured with Key Vault Secrets User permissions.
The correct answer correctly identifies that a custom availability monitoring solution is necessary because Standard availability tests do not support response header validation. It also correctly utilizes `TelemetryClient.TrackAvailability()` with `AvailabilityTelemetry` to send availability metrics, and assigns the correct data plane RBAC role (`Key Vault Secrets User`) to allow the Azure Function's managed identity to read the connection string from Key Vault.

Adım Adım Çözüm

1
Determine the type of availability test required.
Standard availability tests in Application Insights do not support response header validation. Therefore, a custom availability test via SDK is required.
Standard tests only allow validating the HTTP status code, response body contents, and SSL certificate status.
2
Implement the custom availability test.
Create an Azure Function that runs on a timer trigger, sends the POST request, asserts the response headers, and reports results using `TelemetryClient.TrackAvailability`.
This registers the custom test runs in the Application Insights Availability database and populates the availability dashboard.
3
Configure secure secret access.
Assign the system-assigned managed identity of the Azure Function the Key Vault Secrets User RBAC role to fetch the Application Insights Connection String.
The function requires data plane access (Secrets User) to read secrets, not management plane access (Contributor).

Anahtar Kavram

Application Insights Custom Availability Monitoring using TrackAvailability and TelemetryClient
Bu soruyu puanla