QuestionQ47

VerifiedSecure, monitor, troubleshoot Azure solutions

You plan to deploy a container to an Azure App Service API app named api1. The source code for api1 is hosted 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.

You need to ensure that the API key remains outside of Git commit history and is available to the container at runtime.

Solution: Hardcode the API key as an environment variable in the Dockerfile.

Does this solution achieve the goal?

Explanation

Hardcoding an API key in a Dockerfile exposes it through the source repository and Git commit history, and can embed it in the container image. For Azure App Service custom containers, externally configured app settings are injected into the container as runtime environment variables, allowing the secret to remain outside the repository.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!