You are developing a C# daemon application that runs on an Azure Virtual Machine. The application must automate the renewal of an Azure Key Vault certificate named 'ssl-cert' which is issued by a non-integrated internal Certificate Authority (CA).
The application must run under a user-assigned managed identity named 'app-identity'. The renewal workflow requires:
1. Retrieving the pending Certificate Signing Request (CSR) generated by Key Vault.
2. Submitting the CSR to the CA and receiving the signed certificate.
3. Merging the signed certificate back into Key Vault to complete the process.
You need to configure the required permissions and implement the code using the Azure.Security.KeyVault.Certificates library.
Which of the following configurations and code segments should you implement?
- Assign the 'app-identity' to the Virtual Machine and grant it the Key Vault Certificates Officer Azure RBAC role. Use the following C# code:
var client = new CertificateClient(new Uri("https://vault.vault.azure.net/"), new DefaultAzureCredential());
CertificateOperation operation = await client.GetCertificateOperationAsync("ssl-cert");
byte[] csr = operation.Csr;
// Submit to CA and receive signedCertBytes
await client.MergeCertificateAsync(new MergeCertificateOptions("ssl-cert", new[] { signedCertBytes }));Answer - BAssign the 'app-identity' to the Virtual Machine and configure a Key Vault Access Policy granting the identity Get and List permissions under Secret Permissions. Use the following C# code:
var client = new CertificateClient(new Uri("https://vault.vault.azure.net/"), new DefaultAzureCredential());
CertificateOperation operation = await client.GetCertificateOperationAsync("ssl-cert");
byte[] csr = operation.Csr;
// Submit to CA and receive signedCertBytes
await client.MergeCertificateAsync(new MergeCertificateOptions("ssl-cert", new[] { signedCertBytes })); - CEnable a system-assigned managed identity on the Virtual Machine, but configure Key Vault access and RBAC roles exclusively for 'app-identity' (the user-assigned identity). Do not assign 'app-identity' to the Virtual Machine. Use the following C# code:
var client = new CertificateClient(new Uri("https://vault.vault.azure.net/"), new DefaultAzureCredential());
CertificateOperation operation = await client.GetCertificateOperationAsync("ssl-cert");
byte[] csr = operation.Csr;
// Submit to CA and receive signedCertBytes
await client.MergeCertificateAsync(new MergeCertificateOptions("ssl-cert", new[] { signedCertBytes })); - DAssign the 'app-identity' to the Virtual Machine and grant it the Key Vault Certificates Officer Azure RBAC role. Configure the application to reference the certificate secret in Azure App Configuration using the key-value reference value '@KeyVault(SecretUri=https://vault.vault.azure.net/secrets/ssl-cert)'. Use the following C# code:
var client = new CertificateClient(new Uri("https://vault.vault.azure.net/"), new DefaultAzureCredential());
CertificateOperation operation = await client.GetCertificateOperationAsync("ssl-cert");
byte[] csr = operation.Csr;
// Submit to CA and receive signedCertBytes
await client.MergeCertificateAsync(new MergeCertificateOptions("ssl-cert", new[] { signedCertBytes }));