skip to Main Content

We have a Linux App Service we’re deploying with terraform and we want it to pull a new docker container every time one is pushed to our registry.

We’re building this using this terraform resource:

resource "azurerm_linux_web_app" "name"

To enable continuous deployment we need to enable it in the Deployment Centre or with this command:

az webapp deployment container config --enable-cd true --name name --resource-group rg

We’re using terraform, so we don’t want to need to supplement with CLI commands.

Is there any way to do this in terraform? I can’t see anything relevant in the docs.

2

Answers


  1. Hi we were encountering the same problem and fixed by adding the following app setting in azurerm_linux_web_app:

      app_settings = {
        DOCKER_ENABLE_CI = "true"
      }
    
    Login or Signup to reply.
  2. Apart from the options suggested by Helder Sepulveda and GBI

    To enable continous deployment with your Container registry, Use azurerm_app_service_source_control
    and container_configuration block:-

    Terraform code:-

    provider "azurerm" {
      features {}
    }
    
    resource "azurerm_resource_group" "example" {
      name     = "silicon-rg65"
      location = "West Europe"
    }
    
    resource "azurerm_service_plan" "example" {
      name                = "siliconWebapp921"
      resource_group_name = azurerm_resource_group.example.name
      location            = azurerm_resource_group.example.location
      os_type             = "Linux"
      sku_name            = "P1v2"
    }
    
    resource "azurerm_linux_web_app" "example" {
      name                = "valleylinuxapp761"
      resource_group_name = azurerm_resource_group.example.name
      location            = azurerm_service_plan.example.location
      service_plan_id     = azurerm_service_plan.example.id
    
      site_config {}
    }
    
    resource "azurerm_app_service_source_control" "example" {
    
        container_configuration {
        image_name       = "your_image_name"
        registry_url     = "your_registry_url"
        registry_username = "your_registry_username"
        registry_password = "your_registry_password"
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search