我想用terraform创建一个容器网络。我也想从github部署它。所以我需要在那里管理linux_fx_version属性。如果我没有在terrraform中设置,则在部署容器时会出现错误
Error: Deployment Failed with Error: Error: This is not a container web app. Please remove inputs like images and configuration-file which are only relevant for container deployment.当我在terraform中设置属性时,terraform会在我更改基础结构时应用此设置。
有没有办法将web应用程序容器标记为基于,或者仅在未设置时设置此属性?
发布于 2021-02-23 11:23:20
如果要在设置Azure应用程序服务后设置linux_fx_version属性。您可以使用az webapp config container set进行configure a custom container for Azure App Service。此外,您还可以使用Terraform Provisioner来调用运行local-exec的机器上的进程。
例如,您可以从Docker组合文件提供运行多个Docker容器的Linux应用服务。
provisioner "local-exec" {
command =<<EOT
az webapp config set \
--resource-group ${azurerm_resource_group.main.name} \
--name ${azurerm_app_service.main.name} \
--linux-fx-version "COMPOSE|${filebase64("./compose.yml")}"
EOT
}

否则,要为具有terraform的容器创建web应用程序,您需要使用linux_fx_version来定义要在启动时加载的容器。
如果你没有使用App Service插槽,并且部署是在Terraform之外处理的-可以忽略在Terraform的生命周期块中使用ignore_changes对配置中特定字段的更改,例如:
resource "azurerm_app_service" "test" {
# ...
site_config = {
# ...
linux_fx_version = "DOCKER|appsvcsample/python-helloworld:0.1.2"
}
lifecycle {
ignore_changes = [
"site_config.0.linux_fx_version", # deployments are made outside of Terraform
]
}
}有关更多信息,请阅读examples of deploying Web App for Containers (Azure App Service) with terraform 和examples of using the App Service Resources。
https://stackoverflow.com/questions/66296190
复制相似问题