Closed puteulanus closed 1 year ago
Hey, thank you for reporting this. Sounds like Azure API bug to be honest.
Update: It may cause by repeated creation and destruction of resources with a fixed name.
Solution: Add random string to resource name.
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.50.0"
}
random = {
source = "hashicorp/random"
version = "2.3.0"
}
}
}
resource "random_string" "resource_code" {
length = 5
special = false
upper = false
}
resource "azurerm_storage_account" "dev" {
name = "somenamestorage${random_string.resource_code.result}"
resource_group_name = azurerm_resource_group.dev.name
location = azurerm_resource_group.dev.location
account_tier = "Standard"
account_replication_type = "LRS"
account_kind = "StorageV2"
static_website {
index_document = "index.html"
}
tags = {
environment = "staging"
}
}
It fixed the problem in my case.
Is there a work around or stable TF version and Azure arm version that I can use as a workaround for this bug?
While creating container after storage account I am getting error 404 resource not found where as TF apply state Storage account created.
Error on my TF apply stage: module.storage.azurerm_storage_account.storage: Still creating... [10s elapsed] module.storage.azurerm_storage_account.storage: Still creating... [20s elapsed] module.storage.azurerm_storage_account.storage: Creation complete after 26s [id=xxxxxxxxx] module.storage.azurerm_storage_container.container: Creating...
Error: failed creating container: failed creating container: containers.Client#Create: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The specified resource does not exist.\nRequestId:81bb6095-a01e-0049-0512-419855000000\nTime:2021-05-04T18:20:43.7789311Z"
I'm having the same error on TF apply:
ā Error: Error retrieving Azure Storage Account "livepushlpsdev1": storage.AccountsClient#GetProperties: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="StorageAccountNotFound" Message="The storage account livepushlpsdev1 was not found." ā ā with azurerm_storage_account.to_monitor, ā on storage.tf line 1, in resource "azurerm_storage_account" "to_monitor": ā 1: resource "azurerm_storage_account" "to_monitor" { ā
I've tried the suggestions listed here but no luck. Also my config is as follows:
resource "azurerm_storage_account" "to_monitor" { name = "${module.resource_info.lower_short_name}1" resource_group_name = azurerm_resource_group.group1.name location = azurerm_resource_group.group1.location account_tier = "Standard" account_replication_type = "LRS" enable_https_traffic_only = true account_kind = "StorageV2"
timeouts { create = "60m" }
identity { type = "SystemAssigned" }
network_rules { default_action = "Allow" ip_rules = [] bypass = ["AzureServices"] virtual_network_subnet_ids = [azurerm_subnet.example.id] }
tags = { environment = var.environment } }
Error on my TF apply stage: module.storage.azurerm_storage_account.storage: Still creating... [10s elapsed] module.storage.azurerm_storage_account.storage: Still creating... [20s elapsed] module.storage.azurerm_storage_account.storage: Creation complete after 26s [id=xxxxxxxxx] module.storage.azurerm_storage_container.container: Creating...
Error: failed creating container: failed creating container: containers.Client#Create: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The specified resource does not exist.\nRequestId:81bb6095-a01e-0049-0512-419855000000\nTime:2021-05-04T18:20:43.7789311Z"
If you have network rules on the storage account, try adding a service_endpoint to the subnet resource, it fixed my issue:
resource "azurerm_subnet" "example" { name = "${module.resource_info.upper_short_name}-SUBNET" resource_group_name = azurerm_resource_group.group1.name virtual_network_name = azurerm_virtual_network.example.name address_prefixes = ["10.0.1.0/24"] service_endpoints = [ "Microsoft.Storage" ] }
@therodfather I dont have service end point however I removed the entire network acl from storage block and tired, it works sometimes and it fails most of the times with 404, reruinningthe pipeline the 2nd time passes.
esource "azurerm_storage_account" "storage" {
name = var.sa_name
resource_group_name = var.test_rg_name
location = var.location
account_tier = var.account_tier
account_replication_type = var.account_replication_type
min_tls_version = "TLS1_2"
enable_https_traffic_only = "true"
tags = var.tags
}
resource "azurerm_storage_account_network_rules" "acl" { resource_group_name = var.test_rg_name storage_account_name = azurerm_storage_account.storage.name default_action = "Deny" bypass = [
"AzureServices"
]
ip_rules = var.storage_account_ip_rules
}
The same thing happens with azurerm_storage_data_lake_gen2_filesystem
, the example from docs doesn't work most of the time (the account is created but it errors out when creating the containers and it works when running it again):
azurerm_storage_account.example: Still creating... [20s elapsed]
azurerm_storage_account.example: Creation complete after 21s [id=/subscriptions/.../resourceGroups/example-resources/providers/Microsoft.Storage/storageAccounts/examplestorageacc]
azurerm_storage_data_lake_gen2_filesystem.example: Creating...
Error: Error creating File System "example" in Storage Account "examplestorageacc": datalakestore.Client#Create: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The specified resource does not exist.\nRequestId:9d361ae2-...\nTime:2021-05-11T06:08:50.6863617Z"
Adding a 2 min time_sleep
didn't help.
The only thing that worked was what @puteulanus originally suggested, adding a random string to the storage account name. This seems to be an issue with repeateadly destroying and recreating the storage account using the same name.
I've also tried various versions of this provider from 2.47 to 2.58 and none worked, so sounds like an Azure API issue but any such issue should be handled by this provider.
@alexandruanghel I can confirm this works in Tf version 1.33. But thats way too old. My workaround was to use Arm with TF deployment. And that worked just fine.
This duplicates to #13070, especially just for recreating the same named storage account as is mentioned at: https://github.com/hashicorp/terraform-provider-azurerm/issues/10872#issuecomment-793501019.
Thanks for opening this issue. This was a problem in the 2.x version of the provider which is no longer actively maintained. If this is still an issue with the 3.x version of the provider please do let us know by opening a new issue, thanks!
Hi I faced with this issue Saved the plan to: main.tfplan
To perform exactly these actions, run the following command to apply: terraform apply "main.tfplan" PS C:\EPAM\AZ-cources\cloudx-java-azure-dev\petstore\terra\pet-storage-modules> terraform apply main.tfplan module.azurerm_storage_account.azurerm_storage_account.sa: Destroying... [id=/subscriptions/cc3d673b-7b49-4b4a-8034-d02ef8cf8167/resourceGroups/pet-storage/providers/Microsoft.Storage/storageAccounts/petstoragestorageaccount] module.azurerm_storage_account.azurerm_storage_account.sa: Destruction complete after 4s module.azurerm_storage_account.azurerm_storage_account.sa: Creating... module.azurerm_storage_account.azurerm_storage_account.sa: Still creating... [10s elapsed] module.azurerm_storage_account.azurerm_storage_account.sa: Still creating... [20s elapsed] ā· ā Error: retrieving share properties for Storage Account (Subscription: "cc3d673b-7b49-4b4a-8034-d02ef8cf8167" ā Resource Group Name: "pet-storage" ā Storage Account Name: "petstoragestorageaccount"): storage.FileServicesClient#GetServiceProperties: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The specified resource does not exist.\nRequestId:63aee3e1-601a-0072-2d73-daa9ff000000\nTime:2023-08-29T12:25:17.5687769Z" ā ā with module.azurerm_storage_account.azurerm_storage_account.sa, ā on ..\storage-account\main.tf line 1, in resource "azurerm_storage_account" "sa": ā 1: resource "azurerm_storage_account" "sa" {
My TF file
resource "azurerm_storage_account" "sa" { name = var.name resource_group_name = var.resource_group_name location = var.location account_tier = var.account_tier account_replication_type = var.account_replication_type allow_nested_items_to_be_public = false blob_properties{ versioning_enabled = true } }
This thread is getting a little confused. I think that @therodfather raised a different error than what was originally brought up by @puteulanus. These have different solutions.
I think that @therodfather and @smits23 were running into the issue brought up in this thread.
I think @puteulanus and @DmytroFesyk were running into an issue related to this issue. Somewhere along the lines, Terrraform flagged the storage accounts as tainted and is trying to delete them and then immediately stand them up. It takes a bit of time to delete storage accounts, so we wind up going in circles and throwing 404 errors.
I'm going to lock this issue because it has been closed for 30 days ā³. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Terraform (and AzureRM Provider) Version
Terraform v0.14.7 azurerm v2.50.0
Affected Resource(s)
azurerm_storage_account
Terraform Configuration Files
Debug Output
blob endpoint:
Expected Behaviour
Create a storage account can be used normally.
Actual Behaviour
static_website
static_website
, create success, but get error in static website tab and cors tab in web portalResourceNotFound
Steps to Reproduce
terraform apply
Important Factoids
References
0000