0

我们正在使用通过 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"]}"
#}
4

1 回答 1

0

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

于 2020-07-20T16:24:13.113 回答