Deploy an Azure Web App for Containers with Terraform
If you are doing modern web development these days, chances are high that you do it with Docker Containers. If you are creating modern cloud architectures these days, chances are high, that you do it with automation tools like Terraform.
But if you want to use Azure Web Apps as your container host, the Terraform documentation is missing dedicated configuration details for containers on App Services. Luckily, I found some further information about that in several GitHub Issues, so it is time to bring all the details together.
Some hidden traps to bring attention to is, that reserved = true
has to be set for App Service Plans on Linux (for whatever reason it will otherwise create a Windows Plan for you). Due to a bug in the Azure App Service CLI, it is also important, to set WEBSITES_ENABLE_APP_SERVICE_STORAGE = false
.
If you want to give it a try, make sure that Terraform and the Azure CLI are installed. Then open a console or terminal and navigate to the Terraform file’s directory and login to the Azure CLI
az login
If your account is associated to more than one tenant or subscription then you can switch to the specific one you want to work with now using the following command.
az account set --subscription {subscription_id}
Now run Terraform so that it provisions the environment.
terraform init
terraform apply