azure - Terraform 为 Linux 容器创建应用程序服务

标签 azure azure-devops terraform terraform-provider-azure

我大家。 我正在尝试使用 terraform 为我的 docker 镜像创建 azure 应用程序服务,但显然默认情况下会为 Windows 创建此资源,即使我的 app_service_plan 配置为适用于 Linux 环境。 我的配置如下:

resource "azurerm_app_service_plan" "ASP-name" {
  location = var.location
  name = "ASP-name"
  resource_group_name = <resource-group>
  is_xenon = false
  kind = "Linux"
  maximum_elastic_worker_count = 1
  per_site_scaling = false
  reserved = true
  sku {
    capacity = 1
    size = "P1v2"
    tier = "PremiumV2"
  }
}

resource "azurerm_app_service" "app-name" {
  app_service_plan_id = azurerm_app_service_plan.ASP-name.id
  location = var.location
  name = "app-name"
  resource_group_name = <resource-group>
  app_settings = {
    ASPNETCORE_ENVIRONMENT = "Production"
    "DOCKER_REGISTRY_SERVER_PASSWORD"           = "value"
    "DOCKER_REGISTRY_SERVER_URL"                = "value"
    "DOCKER_REGISTRY_SERVER_USERNAME"           = "value"
  }
  client_affinity_enabled = false
  client_cert_enabled = false
  enabled = true

}

有人可以告诉我我做错了什么吗?

最佳答案

This sample提供运行单个 Docker 容器的 Linux 应用服务。您需要为 docker 镜像提供 linux_fx_version

resource "azurerm_app_service_plan" "ASP-name" {
  location = var.location
  name = "ASP-name"
  resource_group_name = <resource-group>

  kind = "Linux"
  maximum_elastic_worker_count = 1
  per_site_scaling = false
  reserved = true
  sku {
    capacity = 1
    size = "P1v2"
    tier = "PremiumV2"
  }
}

resource "azurerm_app_service" "app-name" {
  app_service_plan_id = azurerm_app_service_plan.ASP-name.id
  location = var.location
  name = "app-name"
  resource_group_name = <resource-group>

  site_config {
  app_command_line = ""
  linux_fx_version = "DOCKER|appsvcsample/python-helloworld:latest"
}

  app_settings = {
   
    "DOCKER_REGISTRY_SERVER_PASSWORD"           = "value"
    "DOCKER_REGISTRY_SERVER_URL"                = "value"
    "DOCKER_REGISTRY_SERVER_USERNAME"           = "value"
  }
  client_affinity_enabled = false
  client_cert_enabled = false
  enabled = true

}

关于azure - Terraform 为 Linux 容器创建应用程序服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67410585/

相关文章:

windows - 使用 azure CLI 2.0 从自己创建的自定义镜像创建 Windows 虚拟机时出现问题

azure - 在 Azure Pipelines 中缓存 node_modules 比安装它们需要更长的时间

javascript - 如何使用 Azure 移动服务中的使用逻辑验证数据

powershell - Azure 网站 - 使用 PowerShell 或跨平台 CLI 配置 SSL 绑定(bind)

azure - 使用 Azure Pipelines 部署和运行 .exe 文件

Terraform 变量和计数 = 0

terraform - 是否可以使用 terraform 为变量添加别名?

terraform - 如何使用 Terraform 在 RDS 上应用 SQL 脚本

azure - 使用 Select-Object 更改属性的数据类型并添加计算属性

azure - 如何删除孤立的 DevOps 服务连接?