Microsoft Azure Developer Associate AZ-204 Practice Question
You are building an ASP.NET Core web app that authenticates to a service by using a client certificate. The certificate is stored in an Azure Key Vault named ContosoVault and was imported as an exportable PFX file. At start-up you must load the certificate with its private key into an X509Certificate2 object in memory. A DefaultAzureCredential instance named credential is already available. Which C# approach should you implement?
Instantiate a CertificateClient, call GetCertificateAsync("clientCert"), and pass the returned Certificate.Content bytes to the X509Certificate2 constructor.
Instantiate a SecretClient with the vault URI and credential, call GetSecretAsync("clientCert"), convert the Value to byte[], then create the X509Certificate2 object from the byte array.
Use Azure CLI inside the app to run az keyvault certificate download and load the downloaded file into an X509Certificate2 object.
Instantiate a KeyClient, call GetKeyAsync("clientCert"), extract the key material, and build the X509Certificate2 object from it.
When a PFX certificate is stored in Azure Key Vault, the private key material is kept in a hidden secret that shares the certificate's name. To obtain the complete PFX payload (public certificate and private key), the application must call SecretClient.GetSecretAsync on the secrets collection, then convert the returned Base-64 string into a byte array and pass it to the X509Certificate2 constructor.
CertificateClient.GetCertificateAsync only returns the public part of the certificate in DER format, so the resulting X509Certificate2 will lack a private key. KeyClient works with cryptographic keys, not certificates, and GetKeyAsync cannot return a PFX. The Azure CLI is irrelevant inside application code.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is X509Certificate2 in C#?
Open an interactive chat with Bash
What is the purpose of DefaultAzureCredential in Azure SDK?
Open an interactive chat with Bash
How does SecretClient.GetSecretAsync work in Azure Key Vault?
Open an interactive chat with Bash
Microsoft Azure Developer Associate AZ-204
Implement Azure security
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .