Skill 1.1.3

Deploy containers to Azure App Service, including configuring App Service to supply environment variables and secrets

Key Concepts

A Linux web app on an App Service plan pulls a custom image from a registry and runs it behind the platform's load balancer, TLS termination and scaling. The app can pull from ACR with a system-assigned or user-assigned managed identity that holds AcrPull. App Service expects the container to listen on port 80 or 8080; other ports are set with the WEBSITES_PORT app setting. Continuous deployment can redeploy the app when a new image is pushed, and deployment slots allow a new image to be warmed up and swapped into production.

App settings are injected into the container as environment variables, and connection strings are injected with a type prefix. A setting can be marked as a slot setting so that it stays with a slot during a swap. Secrets should not be stored as plain values: a Key Vault reference such as @Microsoft.KeyVault(SecretUri=https://VAULT.vault.azure.net/secrets/db-password/) lets App Service fetch the value with the app's managed identity, and an App Configuration reference does the same for settings stored in App Configuration.