terraform-provider-azurerm: azurerm: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded

Terraform (and AzureRM Provider) Version

Hi, we having that on: azurerm version = “=2.37.0” version = “=2.41.0” version = “=2.30.0”

Terraform Version

terraform is written in Terraform 12 features

v13.5

Affected Resource(s)

azurerm_storage_share

Terraform Configuration Files

resource "azurerm_storage_share" "storage_share" {
  count                = var.file_share_enabled ? 1 : 0
  name                 = var.file_share_name
  storage_account_name = element(azurerm_storage_account.storage_account.*.name, 0)
  quota                = 2048

}

Debug Output

2020/12/29 18:21:53 [TRACE] dag/walk: vertex "module.storage_account (close)" is waiting for "module.storage_account.output.file_share_id (expand)"
2020/12/29 18:21:53 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/azurerm\"] (close)" is waiting for "module.storage_account.azurerm_storage_share.storage_share (expand)"
2020/12/29 18:21:53 [TRACE] dag/walk: vertex "root" is waiting for "module.storage_account (close)"
2020/12/29 18:21:55 [TRACE] dag/walk: vertex "module.storage_account.output.file_share_id (expand)" is waiting for "module.storage_account.azurerm_storage_share.storage_share (expand)"
2020/12/29 18:21:58 [TRACE] dag/walk: vertex "module.storage_account (close)" is waiting for "module.storage_account.output.file_share_id (expand)"
2020/12/29 18:21:58 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/azurerm\"] (close)" is waiting for "module.storage_account.azurerm_storage_share.storage_share (expand)"
2020/12/29 18:21:58 [TRACE] dag/walk: vertex "root" is waiting for "module.storage_account (close)"
2020/12/29 18:22:00 [TRACE] dag/walk: vertex "module.storage_account.output.file_share_id (expand)" is waiting for "module.storage_account.azurerm_storage_share.storage_share (expand)"
2020/12/29 18:22:03 [ERROR] eval: *terraform.EvalRefresh, err: Error retrieving File Share "thnxthnxfs" (Account "thnxthnxsa" / Resource Group "thnxthnx-rg"): shares.Client#GetProperties: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded
2020/12/29 18:22:03 [ERROR] eval: *terraform.EvalSequence, err: Error retrieving File Share "thnxthnxfs" (Account "thnxthnxsa" / Resource Group "thnxthnx-rg"): shares.Client#GetProperties: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded

Expected Behaviour

We expect our state refresh successfully, it is happening on Plan stage, first apply goes without any issues, at the moment we are using -refresh=false as a workaround

Actual Behaviour

Error: Error retrieving File Share "fthnxthnxfs" (Account "fthnxthnxsa" / Resource Group "fthnxthnx-rg"): shares.Client#GetProperties: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded

After 10 minutes of refreshing of the state, We also have 4 other Private Endpoints (after we added them refresh took from ~30 seconds to 5 minutes, after we added fifth Private endpoint for File Share it stopped refreshing and always failing at 10 minutes)

Steps to Reproduce

resource "azurerm_storage_account" "storage_account" {
  count                     = var.enabled ? 1 : 0
  name                      = var.storage_account_name
  resource_group_name       = var.resource_group_name
  location                  = var.location
  account_kind              = var.account_kind
  account_tier              = var.account_tier
  account_replication_type  = var.account_replication_type
  enable_https_traffic_only = var.enable_https_traffic_only
  access_tier               = var.access_tier

  identity {
    type = "SystemAssigned"
  }

  network_rules {
    default_action             = var.network_rules_default_action
    bypass                     = var.network_rules_bypass
    ip_rules                   = var.network_rules_allowed_ip_ranges
    virtual_network_subnet_ids = var.network_rules_allowed_subnet_ids
  }


  tags = merge(
    var.tags,
    {
      "Name" = var.storage_account_name
    },
  )
}
resource "azurerm_storage_share" "storage_share" {
  count                = var.file_share_enabled ? 1 : 0
  name                 = var.file_share_name
  storage_account_name = element(azurerm_storage_account.storage_account.*.name, 0)
  quota                = 2048

} 

module "private_endpoint_sa_file_share" {
    source = "../module-azure-private-endpoint"
    name                            = "thnxthnx"
    location                        = var.location
    resource_group_name             = var.cluster_app_rg
    subnet_id                       = var.cluster_app_subnet_id
    private_endpoint_resource_id    = element(azurerm_storage_account.storage_account.*.id, 0)
    subresource_names               = ["file"]
    private_endpoint_enabled        = var.private_endpoint_enabled
    private_dns_zone_ids            = [module.private_dns_zone_storage_account_file_share.id]
    private_dns_name                = module.private_dns_zone_storage_account_file_share.name
}

module "private_dns_zone_storage_account_file_share" {
    source = "../module-azure-private-dns-zone"
    env                             = var.env
    dns_zone_name                   = "privatelink.file.core.windows.net"
    resource_group_name             = var.cluster_app_rg
    cluster_app_network_id          = var.cluster_app_network_id
}
  1. terraform apply

Notes: On azurerm providers 2.37 - 2.41 issue description not explaining anything:

Error: shares.Client#GetProperties: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 49
  • Comments: 20 (3 by maintainers)

Most upvoted comments

This’ll be fixed by #2977 - please subscribe to that issue for updates

👍 Same context, but with queues.Client#GetProperties (and we’re not even using queues on this storage account).

in our case, its not a tf code issue. its a matter of allowing our VM thats running terraform outbound access to the storage account private endpoint subnet. you are correct, private endpoint doesnt use nsg, but thats on the inbound side.

we figured out our issue. for some reason querying queue properties doesn’t go through the azure api, but queries the storage account directly. since we are using private endpoint, we had to open up the nsg to allow port 443 connectivity to the storage account subnet from terraform.