Question

Difficulty: MediumCreate and Configure Azure Functions

An enterprise application requires an Azure Function App to retrieve its database connection strings securely from Azure Key Vault without storing credentials in the application configuration. According to your organization's security policy, you must use a user-assigned managed identity instead of a system-assigned managed identity to access the key vault.

Which four actions should you perform in sequence to configure the Function App? To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.

  1. 1Create a user-assigned managed identity and assign it to the Function App.
  2. 2Grant the user-assigned managed identity Secret Get permission on the Azure Key Vault.
  3. 3Configure the Function App setting keyVaultReferenceIdentity with the resource ID of the user-assigned managed identity.
  4. 4Add a new application setting to the Function App with its value formatted as a Key Vault reference.

Answer

To configure the Function App to use a user-assigned managed identity for Key Vault references, you first create the identity and assign it to the Function App. Next, grant the identity Secret Get permission on the Key Vault. Then, set the keyVaultReferenceIdentity app setting to the resource ID of the identity. Finally, add the application setting referencing the secret.
The correct sequence ensures that the user-assigned managed identity is established first, granted permissions to the Key Vault next, mapped as the identity provider for Key Vault references in the application configuration using its full resource ID, and then utilized in the app setting references.

Step-by-Step Solution

1
Create a user-assigned managed identity and assign it to the Function App.
The Function App is associated with the user-assigned identity.
The identity must exist and be registered with the app resource before it can be referenced in App Service config.
2
Grant the user-assigned managed identity Secret Get permission on the Azure Key Vault.
The identity is authorized to access secrets in the vault.
Data plane access is required for the identity to read the secrets referenced by the app settings.
3
Configure the Function App setting keyVaultReferenceIdentity with the resource ID of the user-assigned managed identity.
The Function App runtime is configured to use the specified user-assigned identity for resolving Key Vault references.
The default behavior is to use the system-assigned identity; setting keyVaultReferenceIdentity overrides this and points to the user-assigned identity's Resource ID.
4
Add a new application setting to the Function App with its value formatted as a Key Vault reference.
The application setting is created and references the vault secret dynamically.
Adding the reference syntax allows the host to fetch the secret at startup and inject it as an environment variable.

Key Concept

Configuring Key Vault references in Azure Functions with user-assigned managed identities.
Rate this question