【问题标题】:Terraform - Long running Azure deployment errors outTerraform - 长时间运行 Azure 部署错误
【发布时间】:2018-08-13 19:36:40
【问题描述】:

我们正在使用通过 Bash 窗口中的 shell 脚本执行的 Terraform 来部署应用服务环境。部署应用服务环境需要 1 到 2 小时才能完成。

Terraform 部署在 1 小时后超时,并显示以下错误:

azurerm_template_deployment.ase: Error creating deployment: azure#WaitForCompletion: context has been cancelled: StatusCode=200 -- Original Error: context deadline exceeded

部署实际上并没有停止并最终成功。如果在它完成后(如 Azure 门户中所观察到的)我们重新运行 Terraform 部署,则部署成功完成。

地形日志文件:

https://gist.github.com/Phydeauxman/0f9aa3d1c1379c36e2f8f420d0ae345e

地形配置文件:

provider "azurerm" {
  subscription_id = "${var.sub_id}"
}

data "terraform_remote_state" "rg" {
  backend = "azurerm"

  config {
    storage_account_name = "${var.tfstate_storage_account}"
    container_name       = "${var.tfstate_container}"
    key                  = "${var.tfstate_rgstate_file}"
    access_key           = "${var.tfstate_access_key}"
  }
}

resource "azurerm_resource_group" "ase_rg" {
  name     = "${var.ilbase_rg_name}"
  location = "${data.terraform_remote_state.rg.rglocation}"
}

resource "azurerm_template_deployment" "ase" {
  name                = "ILBASE_ARM_template"
  resource_group_name = "${azurerm_resource_group.ase_rg.name}"

  template_body = <<DEPLOY

  {
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "ilbase_name": {
        "type": "string"
      },
      "ilbase_domain_name": {
        "type": "string"
      },
      "ilbase_subnet_name": {
        "type": "string"
      },
      "ilbase_rglocation": {
        "defaultValue": "East US",
        "type": "string"
      },
      "vnet_id": {
        "type": "string"
      }
    },
    "variables": {
    },
    "resources": [
      {
        "apiVersion": "2016-09-01",
        "type": "Microsoft.Web/hostingEnvironments",
        "name": "[parameters('ilbase_name')]",
        "kind": "ASEV2",
        "location": "[parameters('ilbase_rglocation')]",
        "properties": {
          "name": "[parameters('ilbase_name')]",
          "location": "[parameters('ilbase_rglocation')]",
          "virtualNetwork": {
            "Id": "[parameters('vnet_id')]",
            "Subnet": "[parameters('ilbase_subnet_name')]"
          },
          "internalLoadBalancingMode": "Web, Publishing",
          "multiSize": "Standard_D1_V2",
          "multiRoleCount": 2,
          "workerPools": null,
          "ipsslAddressCount": 0,
          "dnsSuffix": "[parameters('ilbase_domain_name')]",
          "networkAccessControlList": [],
          "frontEndScaleFactor": 15,
          "apiManagementAccountId": null,
          "suspended": false,
          "dynamicCacheEnabled": null,
          "clusterSettings": null
        }
      }
    ],
    "outputs": {
    }
  }

  DEPLOY

  # these key-value pairs are passed into the ARM Template's `parameters` block
  parameters {
    "vnet_id"            = "${data.terraform_remote_state.rg.vnetid}"
    "ilbase_subnet_name" = "${data.terraform_remote_state.rg.sn2name}"
    "ilbase_name"        = "${var.ilbase_name}"
    "ilbase_domain_name" = "${var.ilbase_domain_name}"
  }

  deployment_mode = "Incremental"
}

#output "storageAccountName" {
#  value = "${azurerm_template_deployment.test.outputs["storageAccountName"]}"
#}

【问题讨论】:

  • 你的 tf 文件是什么?
  • 以及详细的错误日志。
  • 你在做什么需要一个多小时才能部署?
  • @ydaetskcoR App Servce Environments 到 1 到 2 小时来配置。

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


【解决方案1】:

似乎没有具体问题,但从AzureRM 2.0 提供程序开始,现在可以添加自定义超时。其次,当 terraform 中不存在资源类型时,仅使用 azurerm_template_deployment 被认为是最佳实践。 App service 是一级资源

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-06
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多