【问题标题】:shares.Client#GetProperties: Failure sending request: StatusCode=0 -- Original Error: context deadline exceededshare.Client#GetProperties:发送请求失败:StatusCode=0 - 原始错误:超出上下文期限
【发布时间】:2022-08-16 22:15:45
【问题描述】:

我在 Azure 中的存储帐户上部署了一个新的文件共享,自从我这样做后,我不再能够执行 terraform 计划,而是收到以下错误:

azurerm_storage_account_customer_managed_key.this[0]: Refreshing state... [id=/subscriptions/**********/resourceGroups/myrg/providers/Microsoft.Storage/storageAccounts/myaccount]
╷
│ Error: shares.Client#GetProperties: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded
│ 
│   with azurerm_storage_share.this[\"share1\"],
│   on main.tf line 155, in resource \"azurerm_storage_share\" \"this\":
│  155: resource \"azurerm_storage_share\" \"this\" {
│ 
╵
Destroy False detailedExitCode: 1
Error detected by Terraform
##[error]Script failed with exit code: 1

我尝试将存储帐户网络设置为公共(从所有网络启用)并且仍然相同。 我尝试过不同的 Terraform 版本(1.2.6、1.0.4、1.2.7、1.2.0)——结果相同。

我在网上查到了这两张票,它们看起来很相似,但还没有收到答案(尽管它们不是来自 Stack Overflow):

https://github.com/hashicorp/terraform-provider-azurerm/issues/17851

https://github.com/hashicorp/terraform-provider-azurerm/issues/2977

目前我已经没有足够的线索进行调查,如果有人对导致问题的原因有新的想法,我将不胜感激。

让我知道我是否可以分享更多信息。

    标签: azure terraform terraform-provider-azure


    【解决方案1】:

    在我的情况下,当我没有清除状态时,我得到了类似的错误 文件(TF),其中存在其他资源,但不存在 天蓝色的门户。(因为我已经在门户中手动删除了它,但仍然 存在于 terraform 状态文件中。)


    我删除了 azure 门户中不存在的资源,然后尝试执行相同的操作。

    或者,如果某些来源存在于天蓝色而不是 terraform 状态文件中。在这种情况下 通过检查 azure 门户和 terraform.tfstate 文件中的资源不匹配,确保使用 terraform import <resource> <resourceId> 类似 azurerm_resource_group | Resources | registry.terraform.iothis SO ref 导入资源。

    例如,资源组可以导入为:

    terraform import azurerm_resource_group.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example
    
    • 确保状态文件与 门户,然后尝试执行。

    我在我的环境中尝试过并且能够执行terraform planterraform apply

    provider "azurerm" {
    
      features {}
    
    }
    resource "azurerm_resource_group" "example" {
      name     = "xxxxxxx"  
      location = "westus2"
    }
    
    resource "azurerm_storage_account" "test" {
      name                     = "acctestacc1234"
      resource_group_name      = azurerm_resource_group.example.name
      location                 = "westus2"
      account_tier             = "Standard"
      account_replication_type = "LRS"
    }
    resource "azurerm_storage_share" "test" {
      name                 = "testkaaccount"
      storage_account_name = azurerm_storage_account.test.name
      quota                = 5
      access_tier          = "TransactionOptimized"
    }
    

    结果:

    另外,请检查位置是否正确给出参考 资源组位置,如果它是在 VM 中创建的,请确保 vm 并且创建的资源位于同一位置。

    参考:

    1. azurerm_storage_share_file | Resources | hashicorp/azurerm | Terraform Registry
    2. Terraform Azure Configure VM Backup Policy Fails - Stack Overflow

    【讨论】:

      猜你喜欢
      • 2022-12-10
      • 1970-01-01
      • 2022-07-06
      • 1970-01-01
      • 2019-05-07
      • 2013-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多