Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Implement and configure security controls for Azure App Service

A worked example

Single answer

A web app runs on Azure App Service. It reads its database connection string from the app setting SqlConnection by using its framework's standard configuration API. The connection string is stored as secret sql-conn in key vault kv-retail-prod and is rotated monthly. The vault uses Azure role-based access control (Azure RBAC) to authorize access to secrets.

The solution must meet these requirements:

  • Application code must not change.
  • The connection string value must not appear in the App Service configuration blades or in deployment artifacts.
  • After a rotation, the app must pick up the new value within 24 hours without anyone restarting it or editing its configuration.
  • No credential used to access the key vault may be stored in app settings.

Which configuration should you implement?

Choose one answer
Why

A versionless Key Vault reference in SqlConnection lets App Service retrieve the secret through the app's managed identity while the code continues reading the same app setting. The reference keeps the secret value out of configuration blades and deployment artifacts. Because the reference does not pin a secret version, App Service adopts rotated values automatically within 24 hours. Azure manages the identity's credentials, so no vault-access credential needs to be stored in app settings.

  • Correct: Set SqlConnection to a versionless Key Vault reference and grant the app's system-assigned managed identity Key Vault Secrets User on the vault. App Service resolves the reference with the managed identity and passes the secret value to the unchanged code. The secret value is kept out of configuration blades and deployment artifacts. Omitting the secret version allows rotated values to be picked up automatically within 24 hours.
  • Not correct: Set SqlConnection to the plain connection string and have a pipeline update the setting after each rotation. Writing the connection string directly to the app setting exposes the value in App Service configuration, even if the pipeline handles it securely.
  • Not correct: Set SqlConnection to a versionless Key Vault reference and store a service principal client secret in another app setting for vault access. Storing a client secret in app settings places a credential where it can be exposed. Key Vault references are resolved by using the app's managed identity, so this stored credential breaks the stated requirement.
  • Not correct: Grant the app's system-assigned managed identity Key Vault Secrets User and read sql-conn with the Key Vault SDK in code. Reading the secret through the SDK requires a code change. Key Vault references deliver the secret through the existing app setting with no change to application code.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free