'unable to delete datalake gen2 terraform code Error:Failure sending request: StatusCode=0

I have deployed datalake gen2 successfully using Terraform. when updating terraform code for azure datalake gen2, I am getting following error

Error: [0m[0m[1mretrieving Path "path01" in File System "filesystem001" in Storage Account "storageaccount01": datalakestore.Client#GetProperties: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded

Releasing state lock. This may take a few moments...
Exit code 1 received from tool '/opt/hostedtoolcache/terraform/1.1.9/x64/terraform'
STDIO streams have closed for tool '/opt/hostedtoolcache/terraform/1.1.9/x64/terraform'
task result: Failed
[error]Error: Terraform Plan failed with exit code: 1
vso[task.issue type=error;]Error: Terraform Plan failed with exit code: 1
vso[task.complete result=Failed;]Error: Terraform Plan failed with exit code: 1

I deleted storage account manually. Remove the storage account code from main.tf. Still the same error :( looks like ".tfstate" is causing the issue, since multiple resources deployed "main.tf" I cannot delete ".tfstate". Is there a way to clear ".tfstate" without impacting other resources?



Solution 1:[1]

Instead of deleting the storage account manually, you can delete a particuler resource using the below command without impacting the .tfstate file.

terraform destroy -target resourcename

The target flag can be used to focus terraform subset of resources.

where resourcename is combination=resource type+logical name

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 RahulKumarShaw-MT