Last active
November 12, 2019 17:21
-
-
Save robinmanuelthiel/2282b4122e973d794054c165d93b48f3 to your computer and use it in GitHub Desktop.
The Terraform documentation is missing dedicated configuration details for containers on App Services. Here is, how it's done. https://pumpingco.de/blog/14472/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use the Azure Resource Manager Provider | |
provider "azurerm" { | |
version = "~> 1.15" | |
} | |
# Create a new Resource Group | |
resource "azurerm_resource_group" "group" { | |
name = "pumpingcode-webapp-containers-demo" | |
location = "northeurope" | |
} | |
# Create an App Service Plan with Linux | |
resource "azurerm_app_service_plan" "appserviceplan" { | |
name = "${azurerm_resource_group.group.name}-plan" | |
location = "${azurerm_resource_group.group.location}" | |
resource_group_name = "${azurerm_resource_group.group.name}" | |
# Define Linux as Host OS | |
kind = "Linux" | |
# Choose size | |
sku { | |
tier = "Standard" | |
size = "S1" | |
} | |
properties { | |
reserved = true # Mandatory for Linux plans | |
} | |
} | |
# Create an Azure Web App for Containers in that App Service Plan | |
resource "azurerm_app_service" "dockerapp" { | |
name = "${azurerm_resource_group.group.name}-dockerapp" | |
location = "${azurerm_resource_group.group.location}" | |
resource_group_name = "${azurerm_resource_group.group.name}" | |
app_service_plan_id = "${azurerm_app_service_plan.appserviceplan.id}" | |
# Do not attach Storage by default | |
app_settings { | |
WEBSITES_ENABLE_APP_SERVICE_STORAGE = false | |
/* | |
# Settings for private Container Registires | |
DOCKER_REGISTRY_SERVER_URL = "" | |
DOCKER_REGISTRY_SERVER_USERNAME = "" | |
DOCKER_REGISTRY_SERVER_PASSWORD = "" | |
*/ | |
} | |
# Configure Docker Image to load on start | |
site_config { | |
linux_fx_version = "DOCKER|appsvcsample/static-site:latest" | |
always_on = "true" | |
} | |
identity { | |
type = "SystemAssigned" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment