Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered
I need to attach a new lakehouse to notebook using rest end point.
Scenario :
I have a notebook which has default lakehouse attached. I need to update to different lakehouse.
Apart from restendpoint , is there any way we can acheive it .
Solved! Go to Solution.
Hi @chetanhiwale,
You can use the following code to attach a different lakehouse as the default one. This would make the lakehouse default through out the session. But make sure you run this code in the first cell
%%configure -f
{
"defaultLakehouse": {
"name": "lakehouse_name",
"id": "lakehouse_id",
"workspaceId": "workspace_id"
}
}
Hi @chetanhiwale ,
you can use notebookutils to achieve this. When you open a new notebook, you can run this code (filling out the workspace specific IDs according to your workspace) which will change the default lakehouse of your target notebook:
import sempy.fabric as fabric
# INSERT YOUR WORKSPACES SPECIFIC INFORMATION HERE
workspace_name = "workspace_id"
item_name = "notebook_name"
replacement_dict = {
"lakehouse_id" : {
"old" : "LH_ID_old",
"new" : "LH_ID_new",
},
"lakehouse_name" : {
"old" : "LH_old",
"new" : "LH_new",
},
"workspace_id_of_lakehouse" : {
"old" : "workspace_id_old",
"new" : "workspace_id_new",
},
}
workspace_id = fabric.resolve_workspace_id(workspace_name)
items = fabric.list_items(workspace=workspace_name)
item_id = items.where(items["Display Name"] == f"{item_name}").dropna().Id.item()
item_type = items.where(items["Display Name"] == f"{item_name}").dropna().Type.item()
definition = notebookutils.notebook.getDefinition(item_name, workspace_id)
for replacement in replacement_dict.keys():
definition = definition.replace(replacement_dict[replacement]["old"], replacement_dict[replacement]["new"])
notebookutils.notebook.updateDefinition(name=item_name, content=definition, workspaceId=workspace_id)
Feel free to try it out and let me know if it works for you. If this resolves your request, kindly mark this as solution to help other users find it. 🙂
Kind regards,
Niels
Thanks @govindarajan_d for helping me out here. The solution you provided really worked for me. Thanks again !!
Hi @chetanhiwale,
Thankyou @govindarajan_d and @ObungiNiels for taking time and providing solution.
we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.
Regards,
Vinay Pabbu
Hi @chetanhiwale ,
you can use notebookutils to achieve this. When you open a new notebook, you can run this code (filling out the workspace specific IDs according to your workspace) which will change the default lakehouse of your target notebook:
import sempy.fabric as fabric
# INSERT YOUR WORKSPACES SPECIFIC INFORMATION HERE
workspace_name = "workspace_id"
item_name = "notebook_name"
replacement_dict = {
"lakehouse_id" : {
"old" : "LH_ID_old",
"new" : "LH_ID_new",
},
"lakehouse_name" : {
"old" : "LH_old",
"new" : "LH_new",
},
"workspace_id_of_lakehouse" : {
"old" : "workspace_id_old",
"new" : "workspace_id_new",
},
}
workspace_id = fabric.resolve_workspace_id(workspace_name)
items = fabric.list_items(workspace=workspace_name)
item_id = items.where(items["Display Name"] == f"{item_name}").dropna().Id.item()
item_type = items.where(items["Display Name"] == f"{item_name}").dropna().Type.item()
definition = notebookutils.notebook.getDefinition(item_name, workspace_id)
for replacement in replacement_dict.keys():
definition = definition.replace(replacement_dict[replacement]["old"], replacement_dict[replacement]["new"])
notebookutils.notebook.updateDefinition(name=item_name, content=definition, workspaceId=workspace_id)
Feel free to try it out and let me know if it works for you. If this resolves your request, kindly mark this as solution to help other users find it. 🙂
Kind regards,
Niels
Thanks @govindarajan_d for answer the question . Is there any other way we can achieve this , by update notebook defination or something else.
Hi @chetanhiwale,
If you are looking to parameterize the configuration, so that you can dynamically pass the lakehouse name, following should work for you.
%%configure -f
{
"defaultLakehouse": {
"name": {
"parameterName": "DefaultLakehouseName",
"defaultValue": "Raw_LH"
},
"id": {
"parameterName": "LakehouseGUID",
"defaultValue": "23adfdsf-2safsdf-wwer"
},
"workspaceId": {
"parameterName": "WorkspaceGUID",
"defaultValue": "adfase-2safsdf-wwer"
}
}
}
And then you can pass parameters in notebook activity in Data pipeline:
You can check the following documentation as well:
Updating notebook definition for changing lakehouse configuration dynamically would be too much work.
Hi @chetanhiwale,
I didn't get your requirement on this. Can you elaborate on what you are trying to do?
Hi @chetanhiwale,
You can use the following code to attach a different lakehouse as the default one. This would make the lakehouse default through out the session. But make sure you run this code in the first cell
%%configure -f
{
"defaultLakehouse": {
"name": "lakehouse_name",
"id": "lakehouse_id",
"workspaceId": "workspace_id"
}
}
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Fabric update to learn about new features.