【问题标题】:Terraform can not create a storage account in AzureTerraform 无法在 Azure 中创建存储帐户
【发布时间】:2019-06-13 04:46:01
【问题描述】:

我有一个 Terraform 脚本,以前可以在 Azure 中创建存储帐户 ok,但今天开始返回错误消息:

azurerm_storage_account.testsa: 1 error(s) occurred: 
* azurerm_storage_account.testsa: Error waiting for Azure Storage Account "terraformtesthubb" to be created: Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=400 -- Original Error: Code="AadClientCredentialsGrantFailure" Message="Failure in AAD Client Credentials Grant Flow."

跟踪日志没有显示任何有用的信息,并且术语 AadClientCredentialsGrantFailure 在 Google 中实际上没有返回任何内容。是什么原因?

【问题讨论】:

    标签: azure terraform


    【解决方案1】:

    我自己回答这个问题,因为 Google 完全让我失望了。

    这原来是 Azure 的一个问题。尽管在任何状态页面中都没有列出任何错误,但该脚本将在美国西部运行,但在美国西部 2 中失败。

    几天后这个问题消失了,所以这是一个间歇性的 Azure 问题。

    编辑

    作为参考,这是脚本。模板部署期间将替换 #{Principal.TenantId} 等标记。

    provider "azurerm" {
      client_id = "#{Principal.Client}"
      client_secret = "#{Principal.Password}"
      subscription_id = "#{Principal.SubscriptionNumber}"
      tenant_id = "#{Principal.TenantId}"
    }
    
    resource "azurerm_resource_group" "testrg" {
      name     = "terraformtesthub#{Octopus.Environment.Name | ToLower}"
      location = "#{Octopus.Environment.Name | ToLower}"
    }
    
    resource "azurerm_virtual_network" "test" {
      name                = "terraformtesthub#{Octopus.Environment.Name | ToLower}"
      address_space       = ["10.0.0.0/16"]
      location            = "${azurerm_resource_group.testrg.location}"
      resource_group_name = "${azurerm_resource_group.testrg.name}"
    }
    
    resource "azurerm_subnet" "test" {
      name                 = "terraformtesthub#{Octopus.Environment.Name | ToLower}"
      resource_group_name  = "${azurerm_resource_group.testrg.name}"
      virtual_network_name = "${azurerm_virtual_network.test.name}"
      address_prefix       = "10.0.2.0/24"
      service_endpoints    = ["Microsoft.Sql", "Microsoft.Storage"]
    }
    
    resource "azurerm_storage_account" "testsa" {
      name                     = "terraformtesthub#{Octopus.Environment.Name | ToLower}"
      resource_group_name      = "${azurerm_resource_group.testrg.name}"
      location                 = "#{Octopus.Environment.Name | ToLower}"
      account_tier             = "Standard"
      account_kind             = "StorageV2"
      account_replication_type = "RAGRS"
        lifecycle {
        prevent_destroy = true
      }
      network_rules {
        ip_rules                   = ["100.0.0.1"]
        virtual_network_subnet_ids = ["${azurerm_subnet.test.id}"]
      }
    }
    

    【讨论】:

    • 你确定不能通过 Terraform 在 west us 2 中创建存储账户吗?
    • 我确定@CharlesXu
    • Azure 支持所有区域的存储帐户。它对我来说效果很好。因此,您可以检查您的服务主体或订阅是否支持美国西部 2 地区。
    • @CharlesXu 这是 Azure 中的间歇性问题。几天后,这个脚本又开始工作了。
    猜你喜欢
    • 2020-06-14
    • 1970-01-01
    • 2020-04-29
    • 2021-10-29
    • 2016-07-17
    • 2019-11-03
    • 2017-11-23
    • 2017-05-04
    • 2020-05-19
    相关资源
    最近更新 更多