< Previous Challenge — Home — Next Challenge >
The eShopOnWeb application is now running on .NET 10 in Azure Container Apps, connected to Azure SQL, Service Bus, and Blob Storage. But connection strings are still plain-text environment variables, and there is no observability into the running system.
This challenge closes both gaps:
- Observability: integrate Application Insights for distributed tracing across
WebandPublicApi - Secret management: move all connection strings to Azure Key Vault, accessed via Managed Identity — no credentials in environment variables or configuration files
- Add
Microsoft.ApplicationInsights.AspNetCoreNuGet package to bothWebandPublicApi - Call
builder.Services.AddApplicationInsightsTelemetry()in eachProgram.cs - Add
APPLICATIONINSIGHTS_CONNECTION_STRINGas an environment variable to both Container Apps in Terraform - Verify telemetry appears in Azure Portal under Application Insights → Live Metrics
Move all secrets into Azure Key Vault:
- Enable system-assigned Managed Identity on both Container Apps (update your Terraform configuration)
- Grant each identity the
Key Vault Secrets Userrole on the Key Vault - Store these secrets in Key Vault:
CatalogConnectionStringIdentityConnectionStringBlobStorageConnectionStringServiceBusConnectionStringApplicationInsightsConnectionString
- Update
Program.csin both projects to load secrets from Key Vault at startup usingDefaultAzureCredential - Remove all plaintext secrets from Container App environment variables — only
KeyVaultUrlshould remain as a non-secret value
Confirm that no plaintext connection strings appear in the Container App environment configuration (check via the Azure Portal or the Azure CLI). Then browse the store and place an order, and verify telemetry appears in Application Insights → Transaction Search.
To complete this challenge successfully, demonstrate:
- Application Insights Live Metrics shows active requests when browsing the store
- A distributed trace for an order placement spans both
WebandPublicApiand is visible in Transaction Search - Both Container Apps show no plaintext connection strings in their environment configuration — only
KeyVaultUrland non-secret config (verify in the Azure Portal or the Azure CLI) - Both Container Apps use system-assigned Managed Identity (visible in Azure Portal → Container App → Identity)
- The application functions correctly end-to-end after the Key Vault migration
- Explain to your coach — what is
DefaultAzureCredentialand why does it work both locally (viaaz login) and in Azure Container Apps (via Managed Identity) without any code change?
- Application Insights for ASP.NET Core
- Azure Key Vault configuration provider for ASP.NET Core
- DefaultAzureCredential — .NET
- Managed Identity for Azure Container Apps
- Key Vault Secrets User role
DefaultAzureCredentialtries credentials in a chain:AzureCliCredentiallocally,ManagedIdentityCredentialin ACA. No code change needed between environments.- Role assignments can take 1–5 minutes to propagate. If you get
403 Forbiddenimmediately, wait and retry. - Application Insights distributed tracing works automatically across HTTP calls with W3C TraceContext headers (default in .NET 6+).