【问题标题】:Terraform template for Azure App Service, LinuxFxVersion has an invalid valueAzure 应用服务的 Terraform 模板,LinuxFxVersion 的值无效
【发布时间】:2022-09-30 04:50:36
【问题描述】:

这就是我的 terraform 模板的样子:

resource \"azurerm_resource_group\" \"example\" {
  name     = \"myAppServiceRG\"
  location = var.location
}

resource \"azurerm_service_plan\" \"example\" {
  name                = var.servicePlanName
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  os_type             = \"Linux\"
  sku_name            = var.pricingTier
  worker_count        = var.nodesInWebFarm
}
resource \"azurerm_linux_web_app\" \"example\" {
  name                = var.appName
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_service_plan.example.location
  service_plan_id     = azurerm_service_plan.example.id

  site_config {
    application_stack {
      docker_image     = var.dockerHubImage
      docker_image_tag = \"latest\"
    }
  }
}

和 parameters.tfvars 文件:

location        = \"West Europe\"
servicePlanName = \"someserviceplan\"
nodesInWebFarm  = 2
pricingTier     = \"P1v2\"
appName         = \"myuniquelinuxwebapplication\"
dockerHubImage  = \"DOCKER|mcr.microsoft.com/dotnet/samples:aspnetapp\"

但由于某些原因,当我尝试执行 terraform apply -var-file .\\parameters.tfvars 时,我收到此错误:

错误:创建 Linux Web 应用程序:(站点名称 \"myuniquelinuxwebapplication\" / 资源组 \"myAppServiceRG\"):web.AppsClient#CreateOrUpdate:发送请求失败:StatusCode=400 -- 原始错误:代码=\"BadRequest\" Message=\"参数 LinuxFxVersion 的值无效。\" Details=[{\"Message\":\"参数 LinuxFxVersion 的值无效。\"},{\"Code\":\"BadRequest\" },{\"ErrorEntity\":{\"Code\":\"BadRequest\",\"ExtendedCode\":\"01007\",\"Message\":\"参数LinuxFxVersion的值无效。 \",\"MessageTemplate\":\"参数 {0} 的值无效。\",\"Parameters\":[\"LinuxFxVersion\"]}}]

有谁知道为什么,以及如何改变这个?

    标签: azure terraform azure-web-app-service terraform-provider-azure


    【解决方案1】:

    听起来你的 Linux 服务计划和你的 docker 容器不匹配。

    我认为将容器更改为 Linux 版本将修复它

    完整的标签在这个页面上(向下滚动一点)https://hub.docker.com/_/microsoft-dotnet-samples

    【讨论】:

    • 但是mcr.microsoft.com/dotnet/samples:aspnetapp 是一个 Linux 标签,不是吗?
    • 任何其他解决方案,如将其与标签 f.e aspnetapp 一起使用都会产生相同的错误
    • 嘿 @user346206 尝试在您的 azurerm_service_plan 资源 registry.terraform.io/providers/hashicorp/azurerm/latest/docs/… 中设置 reserved = true
    【解决方案2】:

    请从 dockerHubImage 中删除 Docker 部分,它应该可以工作。所以它应该像下面这样

    dockerHubImage = "mcr.microsoft.com/dotnet/samples:aspnetapp"

    【讨论】:

      猜你喜欢
      • 2022-01-12
      • 2019-03-29
      • 2022-10-04
      • 2021-07-03
      • 2020-11-10
      • 1970-01-01
      • 1970-01-01
      • 2020-07-22
      • 2019-02-28
      相关资源
      最近更新 更多