Forum Discussion
Write_delta in Fabric Python Notebook Error
- 7 months ago
Hello Ka13 I doubt you'd be able to import mssparkutils as it is a Spark utility and you're using a Python notebook.
Here's a code you can use in Python notebook -
import sempy.fabric as fabric def get_workspace_and_lakehouse_id(target_name="my_lakehouse"): # Workspace ID workspace_id = fabric.get_notebook_workspace_id() # List lakehouse items (your exact signature) items = fabric.list_items(type="Lakehouse", workspace=workspace_id) lakehouse_id = None # Loop through rows (your structure: it[0] = id, it[1] = name) for it in items.values: if it[1] == target_name: lakehouse_id = it[0] break return workspace_id, lakehouse_id print(get_workspace_and_lakehouse_id())
Hi Ka13 ,
You’re getting this error because the deltalake (delta‑rs) library does not support name‑based ABFSS paths in Fabric. It requires the Workspace ID and Lakehouse Item ID, not the workspace or lakehouse name.
You can get both IDs from URL.
Eg. https://app.fabric.microsoft.com/groups/<workspace-id>/lakehouses/<lakehouse-id>?sparkUpgradeToFabric=1&experience=fabric-developer
The correct ABFSS format is:
- Ka137 months ago
Helper II
Asmita_27 - thanks for your reply. How to get the workspace-id and Lakehouse-id in fabric python notebook? , to get the workspace-id and Lakehouse id and then pass it to url
- Asmita_277 months ago
Advocate IV
Hi,
To get the Workspace ID and Lakehouse ID in a Fabric notebook, you can list lakehouses and match by display name.Code:from notebookutils import mssparkutils
def get_lakehouse_ids_by_name(name: str):for lh in mssparkutils.lakehouse.list():if lh.get("displayName") == name:return lh.get("workspaceId"), lh.get("id")raise ValueError(f"Lakehouse named '{name}' not found.")workspace_id, lakehouse_id = get_lakehouse_ids_by_name("Write_Delta")print("Workspace ID:", workspace_id)print("Lakehouse ID:", lakehouse_id)- Ka137 months ago
Helper II
Thanks will test and let you know
- deborshi_nag7 months ago
Super User
Hello Ka13 I doubt you'd be able to import mssparkutils as it is a Spark utility and you're using a Python notebook.
Here's a code you can use in Python notebook -
import sempy.fabric as fabric def get_workspace_and_lakehouse_id(target_name="my_lakehouse"): # Workspace ID workspace_id = fabric.get_notebook_workspace_id() # List lakehouse items (your exact signature) items = fabric.list_items(type="Lakehouse", workspace=workspace_id) lakehouse_id = None # Loop through rows (your structure: it[0] = id, it[1] = name) for it in items.values: if it[1] == target_name: lakehouse_id = it[0] break return workspace_id, lakehouse_id print(get_workspace_and_lakehouse_id())- Ka137 months ago
Helper II
Thanks deborshi_nag for your response , tried above it's working.
Yes the mssparkutils did not worked in Python fabric notebook.