Terraform和Azure:无法设置存储帐户

时间:2020-03-02 09:19:27

标签: azure terraform terraform-provider-azure

我正在尝试设置一个存储帐户,但是运行它会导致错误:

Error: Error reading static website for AzureRM Storage Account "sa12345461234512name":
accounts.Client#GetServiceProperties: 
Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: 
Service returned an error. Status=403 Code="AuthorizationPermissionMismatch" 
Message="This request is not authorized to perform this operation using this permission.\n
RequestId:05930d46-301e-00ac-6d72-f021f0000000\n
Time:2020-03-02T09:09:44.9417598Z"

运行OS Windows 10 Pro。

复制步骤(在安装了Azure CLI的Powershell中)

  1. az登录
  2. mkdir dummyFolder
  3. cd dummyFolder
  4. 创建config.tf
  5. terrain init
  6. 地形计划
  7. terraform apply -auto-approve

Config.tf内容

# Configure the Azure Provider
provider "azurerm" {
  version = "=2.0.0"
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "Australia East"
}

resource "azurerm_storage_account" "example" {
  name                     = "sa12345461234512name"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"

  tags = {
    environment = "staging"
  }
}

不确定我缺少什么,所有其他资源都可以正常工作,只是存储帐户即可。

4 个答案:

答案 0 :(得分:1)

这是azure提供程序中的错误,请参阅:https://github.com/terraform-providers/terraform-provider-azurerm/issues/5869

更新您的提供商;它似乎与terraform版本无关。

发件人:

# Configure the Azure Provider
provider "azurerm" {
  # whilst the `version` attribute is optional, we recommend pinning to a given version of the Provider
  version = "=2.0.0"
  features {}
}

收件人:

provider "azurerm" {
  version = "~> 2.1.0" 
  features {}
}

答案 1 :(得分:1)

只需添加此内容,因为以上方法均无效。就我而言,它先不工作,然后第二天又工作,直到晚上不再工作...不更改版本或任何内容,是同一台计算机。

事实证明,我在Windows上运行的Ubuntu上的时间设置存在偏差。只需运行withDockerContainer(args: '--cpus="1.0" --entrypoint="" -e DEBUG=cypress:* -u root', image:'cypress/included:5.0.0') { //Your code } 来更新时间即可解决问题。

答案 2 :(得分:0)

发现了问题。它与Terraform有关。 刚刚检查了更新,并注意到0.12.21已用完(我当时正在运行0.12.20)。

好像运行AzureARM 2.0.0一样,实际上必须至少为0.12.21才能使它工作。

答案 3 :(得分:0)

遇到与@tesharp相同的问题。 在我的Ubuntu WSL2上,以下命令解决了该问题:

sudo hwclock -s