Question 83 of 179 from exam AZ-204: Developing Solutions for Microsoft Azure

Question 83 of 179 from exam AZ-204: Developing Solutions for Microsoft Azure

Question

DRAG DROP - You are developing an Azure solution.

You need to develop code to access a secret stored in Azure Key Vault.

How should you complete the code segment? To answer, drag the appropriate code segments to the correct location.

Each code segment may be used once, more than once, or not at all.

You may need to drag the split bar between panes or scroll to view content.

NOTE: Each correct selection is worth one point.

Select and Place:

Code segments

DefaultAzureCredential

ClientSecretCredential

CloudClients

SecretClient

Answer Area

string vari = Environment .GetEnvironmentVariable("KEY_VAULT_URI");

var var2 = new Code segment ( new Uri(var1), new Code segment QO)

Explanations

Code segments Answer Area

string vari = Environment .GetEnvironmentVariable("KEY_VAULT_URI");

ClientSecretCredential! | Jo. var2 = new |SecretClient (new Uri(var1), new |DefaultAzureCredential | ());

CloudClients

Box 1: SecretClient - Box 2: DefaultAzureCredential - In below example, the name of your key vault is expanded to the key vault URI, in the format "https://<your-key-vault-name>.vault.azure.net"

This example is using 'DefaultAzureCredential()' class from Azure Identity Library, which allows to use the same code across different environments with different options to provide identity.

string keyVaultName = Environment.GetEnvironmentVariable("KEY_VAULT_NAME"); var kvUri = "https://" + keyVaultName + ".vault.azure.net"; var client = new SecretClient(new Uri(kvUri), new DefaultAzureCredential()); Reference: https://docs.microsoft.com/en-us/azure/key-vault/secrets/quick-create-net.