You are migrating a deprecated multi-step web test that monitors an e-commerce checkout flow to a modern availability monitoring solution in Azure. The workflow requires logging in with a test account, searching for a product, and verifying the checkout service response.
You decide to implement a custom availability test using a Timer-triggered Azure Function and the Application Insights SDK. The function must run securely, retrieve test account credentials from Azure Key Vault, and report the workflow status to Application Insights.
You need to implement the telemetry reporting and ensure the function runs securely and successfully sends telemetry.
Which two actions should you perform? Select two.
- Instantiate TelemetryClient by passing a TelemetryConfiguration initialized with the Application Insights connection string, and call the TrackAvailability method with an AvailabilityTelemetry instance.Answer
- Grant the Azure Function's system-assigned managed identity the Key Vault Secrets User role on the Key Vault that stores the test credentials, and reference those credentials in the function's application settings using Key Vault references.Answer
- CInstantiate TelemetryClient using the default parameterless constructor without passing a connection string, relying on the local runtime environment to automatically inject the configuration.
- DReference the test credentials in the function's application settings using the @Microsoft.KeyVault syntax, without configuring any access policies or Azure RBAC roles on the Key Vault.
Answer
To implement the custom availability monitoring solution, you must instantiate the TelemetryClient using a TelemetryConfiguration initialized with the Application Insights connection string and call TrackAvailability with an AvailabilityTelemetry instance. Additionally, you must grant the function's managed identity the Key Vault Secrets User role to allow resolving Key Vault references in the application settings.
Migrating deprecated multi-step tests requires executing custom logic (such as logging in, searching, and checking out) in code, which can be done using a Timer-triggered Azure Function. To report custom availability telemetry, the Azure Function must use the Application Insights SDK. Instantiating TelemetryClient with a configuration containing the connection string ensures the telemetry is directed to the correct resource. Furthermore, retrieving credentials securely requires using Key Vault references in the application settings, which fails unless the function's system-assigned managed identity is granted authorization, such as the Key Vault Secrets User role.
Step-by-Step Solution
Key Concept
Custom availability monitoring with Application Insights SDK using Azure Functions and Key Vault integration