'Getting ShareBeingDeleted error while updating protocol in azure storage share from SMB to NFS via Terraform
In Terraform, Getting ShareBeingDeleted error while updating protocol in azure storage share from SMB to NFS. (Also for NFS to SMB)
I already deployed the azure storage share with SMB protocol using below source
resource "azurerm_storage_share" "example" {
name = "mystrgshr456"
storage_account_name = "mystrgacnt456"
quota = 100
enabled_protocol = "SMB"
}
Now am planning to update the protocol from SMB to NFS. So have updated the source code as shown below.
resource "azurerm_storage_share" "example" {
name = "mystrgshr456"
storage_account_name = "mystrgacnt456"
quota = 100
enabled_protocol = "NFS"
}
After changing source, ran the terraform apply --auto-approve command. And getting below error.
$ terraform apply --auto-approve
azurerm_storage_share.example: Refreshing state... [id=https://mystrgacnt456.file.core.windows.net/mystrgshr456]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# azurerm_storage_share.example must be replaced
-/+ resource "azurerm_storage_share" "example" {
~ enabled_protocol = "SMB" -> "NFS" # forces replacement
~ id = "https://mystrgacnt456.file.core.windows.net/mystrgshr456" -> (known after apply)
~ metadata = {} -> (known after apply)
name = "mystrgshr456"
~ resource_manager_id = "/resourceGroups/tf-azure/providers/Microsoft.Storage/storageAccounts/mystrgacnt456/fileServices/default/fileshares/mystrgshr456" -> (known after apply)
~ url = "https://mystrgacnt456.file.core.windows.net/mystrgshr456" -> (known after apply)
# (2 unchanged attributes hidden)
- timeouts {}
}
Plan: 1 to add, 0 to change, 1 to destroy.
azurerm_storage_share.example: Destroying... [id=https://mystrgacnt456.file.core.windows.net/mystrgshr456]
azurerm_storage_share.example: Destruction complete after 3s
azurerm_storage_share.example: Creating...
azurerm_storage_share.example: Still creating... [10s elapsed]
azurerm_storage_share.example: Still creating... [20s elapsed]
azurerm_storage_share.example: Still creating... [30s elapsed]
╷
│ Error: creating Share "mystrgshr456" (Account "mystrgacnt456" / Resource Group "tf-azure"): shares.Client#Create: Failure sending request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="ShareBeingDeleted" Message="The specified share is being deleted. Try operation later.\nRequestId:532d2678-b01a-00f4-4344-149210000000\nTime:2022-01-28T12:45:49.9175758Z"
│
│ with azurerm_storage_share.example,
│ on main.tf line 2, in resource "azurerm_storage_share" "example":
│ 2: resource "azurerm_storage_share" "example" {
│
╵
But storage share protocol has been successfully updated in azure portal.
Solution 1:[1]
This is a bug from Terraform azurerm Provider where The Storage Share recreation with updated protocol gives an error like :
Error: creating Share "example" (Account "expstracc" / Resource Group "exap-rg"): shares.Client#Create: Failure sending request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="ShareBeingDeleted" Message="The specified share is being deleted. Try operation later."
Even though the Storage Share Protocol gets successfully updated and can be seen from Azure Portal.
This will be fixed in this Github Pull Request on the azurerm_storage_share .
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ansuman Bal |
