Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Specify port while deploying a Docker container for Terraform Provider for Azure

I am trying to follow the example of a Linux App Service running a Docker container.

This is my main.tf:

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "${var.prefix}-resources"
  location = var.location
}

resource "azurerm_service_plan" "example" {
  name                = "${var.prefix}-sp-zipdeploy"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  os_type             = "Linux"
  sku_name            = "S1"
}


resource "azurerm_linux_web_app" "example" {
  name                = "${var.prefix}-example"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  service_plan_id     = azurerm_service_plan.example.id

  app_settings = {
    "WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
  }

  site_config {
    application_stack {
      docker_image     = "ghcr.io/moja-global/rest_api_flint.example"
      docker_image_tag = "master"
    }
  }
}

I am able to perform terraform init and terraform apply successfully. However I am not able to access the application. I also see that the running port is missing from the above Terraform configuration. How can we add that and make it work?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Locally I can take the Docker image for a run like:

docker pull ghcr.io/moja-global/rest_api_flint.example:master
docker run --rm -p 8080:8080 ghcr.io/moja-global/rest_api_flint.example

What shall I do to deploy this over App Service using Terraform?

>Solution :

App Service listens on port 80. To route the traffic to port 8080, the one that your container is listening on, add the following to the app_settings section:

WEBSITES_PORT = 8080
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading