Nuke Fabric Workspace
A handy function to delete all Fabric items in a workspace. Run this in a Python notebook in the workspace you want to delete items from. Everything, except that notebook, will be deleted. You need to have contributor+ role in the workspace. Delete t...
fabric.guru2 min read
Great! If we want to delete items from a different workspace instead of the current one, we can change the code as follows.
from tqdm import tqdm import sempy.fabric as fabric
def nuke_workspace(workspace_name): workspace_id = fabric.resolve_workspace_id(workspace_name) items = fabric.list_items(workspace=workspace_id) items_to_delete = items['Id'] client = fabric.FabricRestClient() print(f"{len(items_to_delete)} items will be deleted in workspace {workspace_name}") for item in tqdm(items_to_delete, desc="Deleting items"): client.delete(f"/v1/workspaces/{workspace_id}/items/{item}") remaining_items = fabric.list_items(workspace=workspace_id)['Display Name'].to_list() print(f"Remaining items in workspace {workspace_name}: {remaining_items}")
workspace_name = "Enter_WS_Name"
nuke_workspace(workspace_name)