ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 436 - AZ-400 discussion

Report
Export

LAB 1

You need to ensure that an Azure Web App named az400-38443478-main can retrieve secrets from an Azure key vault named az400-3844J478-kv1 by using a system managed identity The solution must use the principle of least privilege.

A.
See the solution below in explanation
Answers
A.
See the solution below in explanation
Suggested answer: A

Explanation:

To ensure that your Azure Web App named az400-38443478-main can retrieve secrets from an Azure Key Vault named az400-3844J478-kv1 using a system managed identity with the principle of least privilege, follow these detailed steps:

Enable a System Managed Identity for the Azure Web App:

Navigate to the Azure Portal.

Go to the Azure Web App az400-38443478-main.

Select Identity under the Settings section.

In the System assigned tab, switch the Status to On.

Click Save to apply the changes.

Grant the Web App Access to the Key Vault:

Go to the Azure Key Vault az400-3844J478-kv1.

Select Access policies under the Settings section.

Click on Add Access Policy.

Choose Secret permissions and select Get and List. This grants the app the ability to read secrets, adhering to the principle of least privilege.

Click on Select principal, search for your Web App name az400-38443478-main, and select it.

Click Add to add the policy.

Don't forget to click Save to save the access policy changes.

Retrieve Secrets in the Web App Code:

In your Web App's code, use the Azure SDK to retrieve the secrets.

For example, in a .NET application, you can use the Azure.Identity and Azure.Security.KeyVault.Secrets namespaces.

Utilize the DefaultAzureCredential class which will automatically use the system managed identity when running on Azure.

using Azure.Identity;

using Azure.Security.KeyVault.Secrets;

var client = new SecretClient(new Uri('https://az400-3844J478-kv1.vault.azure.net/'), new DefaultAzureCredential());

KeyVaultSecret secret = await client.GetSecretAsync('my-secret-name');

string secretValue = secret.Value;

Replace 'my-secret-name' with the actual name of the secret you want to retrieve.

By following these steps, your Azure Web App will be able to securely retrieve secrets from the Azure Key Vault using a system managed identity, without needing to store credentials in the code, and adhering to the principle of least privilege. Remember to replace the placeholder names with the actual names of your Web App and Key Vault.

asked 02/10/2024
Govinda Bhikha
38 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first