Symptoms
- All tables in one catalog, schema or external location fail at once. Typical errors:
java.net.UnknownHostException: stlakeprod.dfs.core.windows.net(account gone, DNS name released)404 ContainerNotFoundorThe specified filesystem does not existDELTA_TABLE_NOT_FOUNDorFileNotFoundExceptionon_delta_log/...json
- Test connection on the external location fails on every check.
- Streams writing to the same account stop with checkpoint read errors.
- Someone ran a resource group cleanup, a Terraform destroy, or deleted "an old container".
Unity Catalog still has the table metadata. Only the files are gone. Recovery is about getting the files back to the same path.
Step 1: freeze and protect (5 minutes)
Caution
Do not
DROPthe affected tables, schemas or catalogs to "clean up". Dropping a managed table schedules its data for deletion, and you will need the metadata to point at the recovered files. Do not create a new storage account with the same name: that blocks account recovery.
- Pause jobs and pipelines that write to the affected catalogs so they don't fail repeatedly or create new data on a replacement account.
- Tell anyone working in Azure to stop changing that resource group.
Step 2: what exactly was deleted?
Get the storage paths from Unity Catalog:
DESCRIBE EXTERNAL LOCATION `el-sales-prod`;
DESCRIBE CATALOG EXTENDED sales_prod; -- managed storage root, if set
DESCRIBE DETAIL sales_prod.silver.orders; -- location column
Check the account and container:
az storage account show -n stlakeprod -g rg-data --query "{id:id, hns:isHnsEnabled}" -o table
az storage container list --account-name stlakeprod --auth-mode login --include-deleted \
--query "[].{name:name, deleted:deleted, version:version}" -o table
Find the delete in the Activity Log (account and container deletes are control-plane operations):
az monitor activity-log list --resource-group rg-data --offset 2d \
--query "[?contains(operationName.value, 'Microsoft.Storage') && contains(operationName.value, 'delete')].{t:eventTimestamp, op:operationName.value, who:caller, status:status.value}" -o table
| Finding | Go to |
|---|---|
| Account does not exist | Step 3a |
Account exists, container listed as deleted | Step 3b |
| Container exists, table folders missing | Step 3c |
| Nothing recoverable in Azure | Step 3d |
Step 3a: recover a deleted storage account
A deleted storage account can be recovered if:
- it was deleted within the last 14 days,
- the resource group still exists (recreate it with the same name if it was deleted),
- no account with the same name has been created since,
- the Key Vault holding its customer-managed key, if any, is recovered first.
Recovery is best-effort and done in the portal: Storage accounts > Restore (or Create > Recover a deleted account, depending on portal version), choose the subscription and account, then restore. If the account isn't listed, open a support request immediately; time matters.
After recovery, check what did not come back with it:
SA=$(az storage account show -n stlakeprod -g rg-data --query id -o tsv)
az role assignment list --scope $SA --query "[].{who:principalName, role:roleDefinitionName}" -o table
az network private-endpoint-connection list --id $SA -o table
az storage account show -n stlakeprod --query "networkRuleSet.{default:defaultAction, rules:resourceAccessRules}"
Re-grant Storage Blob Data Contributor to the access connector's managed identity, re-approve private endpoints, and re-add the resource instance rule for the access connector if they are missing. See access connector 403 runbook for the commands.
Step 3b: restore a soft-deleted container
Requires container soft delete on the account at the time of deletion:
az storage container restore --account-name stlakeprod --auth-mode login \
--name lake --deleted-version <version-from-list>
The container must be restored with its original name, and no new container with that name can exist. If someone already recreated an empty lake container, delete the empty one first, after checking it really is empty.
Step 3c: restore deleted folders
On hierarchical namespace accounts with blob soft delete, deleted directories can be undeleted with their contents:
az storage fs list-deleted-path --account-name stlakeprod -f lake \
--path-prefix sales/silver --auth-mode login \
--query "[].{path:name, id:deletionId, deleted:deletedTime}" -o table
az storage fs undelete-path --account-name stlakeprod -f lake \
--deleted-path-name sales/silver/orders --deletion-id <deletion-id> --auth-mode login
Managed tables live under GUID-named folders in the managed storage root. Restore the whole schema or catalog folder rather than guessing individual paths. Restore the checkpoint folders too.
Note
Account recovery, container soft delete and blob soft delete are separate features. Account recovery does not bring back containers deleted before the account; container restore does not bring back individual blobs deleted earlier. Check each layer.
Step 3d: nothing to recover in Azure
Work from what you have, most complete first:
| Source | How to use it |
|---|---|
| Deep clones or replicated copies in another account or region | CREATE OR REPLACE TABLE ... DEEP CLONE back into place, or repoint the external location |
| Bronze data still in another storage account | Rerun silver and gold pipelines with a full refresh |
| Source systems (databases, Event Hubs Capture, landing zones) | Re-ingest the required history |
Geo-redundant storage does not help here: deletes replicate to the secondary.
Step 4: validate the tables
Once the files are back at the original paths, Unity Catalog uses them without re-registration:
SELECT count(*) FROM sales_prod.silver.orders;
DESCRIBE HISTORY sales_prod.silver.orders LIMIT 5;
Run Test connection on each external location. Then check for tables with partial loss (some data files missing, log intact):
FSCK REPAIR TABLE sales_prod.silver.orders DRY RUN;
FSCK REPAIR TABLE without DRY RUN removes references to missing files from the log. That makes the table readable but loses those rows; only do it if you accept the loss or will reload the data.
Script the check across every table in the affected catalog:
tables = spark.sql("""
SELECT table_catalog, table_schema, table_name
FROM system.information_schema.tables
WHERE table_catalog = 'sales_prod' AND table_type IN ('MANAGED', 'EXTERNAL')
""").collect()
for t in tables:
name = f"`{t.table_catalog}`.`{t.table_schema}`.`{t.table_name}`"
try:
spark.sql(f"SELECT 1 FROM {name} LIMIT 1").collect()
except Exception as e:
print(name, str(e)[:150])
Step 5: restart workloads
- Resume streams on their existing checkpoints if those were restored; otherwise follow the checkpoint recovery steps in deleted streaming checkpoint.
- Resume and repair paused jobs in dependency order: bronze, silver, gold, then BI refreshes.
Prevent it next time
CanNotDeleteresource locks on lake storage accounts and their resource groups.- Enable container soft delete and blob soft delete on lake accounts, with a retention long enough to notice a mistake (check the current maximums).
- Keep Terraform state for storage separate from workspace and compute stacks, with
prevent_destroyon storage accounts. - Exclude lake storage from automated cleanup by tag, and alert on
Microsoft.Storage/storageAccounts/deleteand container delete events in the Activity Log. - Keep a deep clone or replica of critical gold tables in a second account.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get