My team is attempting to create an Azure App Service that uses Windows Docker Containers, using Terraform.
I have tested the docker-basic example, from the Terraform GitHub project, to successfully create a Linux Docker App Service.
Next, I used the Terraform documentation for the azurerm_app_service and azurerm_app_service_plan, to change the main.tf
file to one that will create a Windows Docker App Service, with a Windows IIS Docker image. Here is the updated main.tf
file:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "main" {
name = "${var.prefix}-resources"
location = "${var.location}"
}
resource "azurerm_app_service_plan" "main" {
name = "${var.prefix}-asp"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
kind = "Windows"
reserved = false
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "main" {
name = "${var.prefix}-appservice"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
app_service_plan_id = "${azurerm_app_service_plan.main.id}"
site_config {
app_command_line = ""
windows_fx_version = "DOCKER|windows/servercore/iis:windowsservercore-ltsc2019"
}
app_settings = {
"WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
"DOCKER_REGISTRY_SERVER_URL" = "https://mcr.microsoft.com"
}
}
There are 4 changes. In azurerm_app_service_plan
, the kind
field is now set to "Windows," and the reserved
field is now set to false. In the azurerm_app_service
, the Docker image is specified in the windows_fx_version
field (instead of linux_fx_version
), and the DOCKER_REGISTRY_SERVER_URL
points to the microsoft public docker registry mcr.microsoft.com
(instead of docker.io
)
The Terraform apply is successful, however, the App Service that gets created is not a Docker App Service. It, instead, gets created in the .NET stack configuration. We compared what was created with a Windows Docker App Service that we created in the Azure Portal, and it is clearly not right.
If more changes are needed, or if any of my changes have been in error, my team and I cannot detect what they might be, from the official documentation. Is there something we missed, in the Documentation? Is there a step missing from the Documentation? Is this an actual Terraform bug?