You are developing a C# .NET console application that must retrieve a connection string stored as a secret in Azure Key Vault. The application will run locally during development and as a containerized app in Azure once deployed. You want to connect to the Key Vault using the modern Azure SDK. Which two components are required to successfully authenticate the client and retrieve the secret? (Select two.)
- The DefaultAzureCredential class from the Azure.Identity package to handle authentication.Answer
- The SecretClient class from the Azure.Security.KeyVault.Secrets package to perform secret operations.Answer
- CThe KeyVaultClient class from the Microsoft.Azure.KeyVault package to establish a connection to the vault.
- DA Key Vault reference using the @Microsoft.KeyVault(SecretUri=...) format inside the application code.
Answer
To authenticate and retrieve a secret using the modern Azure SDK, you must use the DefaultAzureCredential class from the Azure.Identity namespace and the SecretClient class from the Azure.Security.KeyVault.Secrets namespace.
To authenticate and retrieve a secret from Azure Key Vault using the modern Azure SDK, the application must construct a DefaultAzureCredential object to handle identity flow and pass it into a newly initialized SecretClient object to communicate with Key Vault.
Step-by-Step Solution
Key Concept
Retrieving secrets from Azure Key Vault using the modern Azure SDK for .NET with token-based Azure Identity authentication.