Key Vault-backed App Service setting for container API key
Short answer
A Storing the API key in Azure Key Vault and referencing it from an App Service application setting keeps the secret out of the GitHub repository and commit history while making it available to api1 at runtime.
Question
You plan to deploy a container to an Azure App Service API app named api1. You host the source code for api1 in a GitHub repository. The container uses the API key at runtime to connect to a backend service. The container must be able to retrieve the API key at runtime without exposing it in the source repository or Git commit history.
Solution: Store the API key in Azure Key Vault and reference it from an App Service application setting.
Does the solution meet the goal?
Key Takeaways
Storing a container's backend API key in Azure Key Vault and surfacing it through an App Service application setting is the correct approach. The Key Vault reference keeps the secret out of the GitHub repository and commit history, while App Service resolves it at runtime so the deployed container can call the backend service. Option A is correct because it satisfies both the secrecy and runtime-availability requirements without hard-coding the key.
Expert Analysis
Key Vault keeps the API key outside the Git repository and provides a dedicated location for secret management. An App Service application setting can reference that secret, allowing the deployed container to obtain the value through its runtime configuration. This meets both conditions: the key is absent from commit history and available when the container runs.
The requirement has two simultaneous tests, and the proposed solution addresses both without relying on the container image or repository contents. The API key is moved into Azure Key Vault, so it is not written into a file that GitHub stores; consequently, it cannot appear in the current branch or in prior commits. The App Service application setting then carries a reference to that Key Vault secret rather than the secret value itself. At runtime, api1 reads the resolved value through its environment/application configuration and uses it for the backend connection. Nothing in the GitHub repository or commit history needs to contain the key, and the running container still receives it.
The mechanism that makes this work, and that the solution implicitly depends on, is an App Service Key Vault reference resolved through the app's managed identity. An application setting can use the form @Microsoft.KeyVault(SecretUri=https://<vault-name>.vault.azure.net/secrets/<secret-name>/<version>); App Service resolves that URI at runtime and injects the secret into the setting the container sees. The identity attached to api1 must be granted read access to the secret—for example, the Key Vault Secrets User role through Azure RBAC, or an equivalent access policy. With that permission in place, the container can read the value as an ordinary environment variable; without it, the reference remains unresolved. The important point for the stated goal is that the reference, not the API key, is what gets configured alongside the app.
Option A is therefore correct. It keeps the key out of the GitHub repository and out of every commit, while the App Service application setting makes the value available to the deployed container at runtime. The setting stores a pointer to Key Vault, so even inspection of the app configuration does not reveal the API key. This also separates secret management from source control: the key can be rotated in Key Vault, and api1 can receive the updated value when the reference is resolved, rather than requiring a new commit or a rebuilt image. The container's runtime code can remain unchanged as long as it reads the expected application setting/environment variable.
Option B would be the right verdict only if the proposed action left the key in the repository, embedded it in the container image, or failed to make it available when api1 runs. Storing the key in Key Vault and referencing it from an application setting does none of those things. It does not require the key to be committed to GitHub, and it does not require the container to hard-code the secret. Rejecting the solution would incorrectly treat the use of an external secret store plus a runtime configuration reference as insufficient, even though that combination satisfies both stated conditions.
There are operational details to get right—managed identity assignment and Key Vault permission, for instance—but those are configuration requirements, not reasons the approach fails the goal. Once the identity can read the secret and the application setting contains the Key Vault reference, the API key remains outside Git and is available to the container through the App Service application setting, so the answer is Yes.
Official Reference
- https://learn.microsoft.com/en-us/azure/app-service/app-service-key-vault-references
- https://learn.microsoft.com/en-us/azure/key-vault/general/overview
These links open the official vendor documentation in a new tab.
Exam Strategy
When a scenario asks whether a secret-handling solution meets a goal, test it against two independent conditions: is the secret removed from source control and images, and can the workload retrieve it at runtime? For Azure App Service containers, a Key Vault reference in an application setting is the standard pattern; do not reject it merely because managed identity or Key Vault permissions must also be configured. Translate “No” into the specific failure it would imply—secret still in Git or unavailable to the running app—and select Yes only when neither failure applies.
Related Analysis
Practice All AI-200 Questions
Access 69 questions with complete answers and detailed explanations.
View Full AI-200 Practice Test →