<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Update Notebook attached lakehouse using code in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4378920#M6466</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/803370"&gt;@chetanhiwale&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%%configure -f 
{
    "defaultLakehouse": { 
        "name": "lakehouse_name",
        "id": "lakehouse_id",
        "workspaceId": "workspace_id"
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jan 2025 04:49:46 GMT</pubDate>
    <dc:creator>govindarajan_d</dc:creator>
    <dc:date>2025-01-24T04:49:46Z</dc:date>
    <item>
      <title>Update Notebook attached lakehouse using code</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4378913#M6465</link>
      <description>&lt;P&gt;I need to attach a new lakehouse to notebook using rest end point.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scenario :&lt;/P&gt;&lt;P&gt;I have a notebook which has default lakehouse attached. I need to update to different lakehouse.&amp;nbsp;&lt;BR /&gt;Apart from restendpoint , is there any way we can acheive it .&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 04:43:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4378913#M6465</guid>
      <dc:creator>chetanhiwale</dc:creator>
      <dc:date>2025-01-24T04:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Update Notebook attached lakehouse using code</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4378920#M6466</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/803370"&gt;@chetanhiwale&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%%configure -f 
{
    "defaultLakehouse": { 
        "name": "lakehouse_name",
        "id": "lakehouse_id",
        "workspaceId": "workspace_id"
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 04:49:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4378920#M6466</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2025-01-24T04:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Update Notebook attached lakehouse using code</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4378947#M6468</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/644992"&gt;@govindarajan_d&lt;/a&gt;&amp;nbsp; for answer the question . Is there any other way we can achieve this , by update notebook defination or something else.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 05:04:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4378947#M6468</guid>
      <dc:creator>chetanhiwale</dc:creator>
      <dc:date>2025-01-24T05:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Update Notebook attached lakehouse using code</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4379043#M6469</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/803370"&gt;@chetanhiwale&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't get your requirement on this. Can you elaborate on what you are trying to do?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 06:07:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4379043#M6469</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2025-01-24T06:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Update Notebook attached lakehouse using code</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4379048#M6470</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/803370"&gt;@chetanhiwale&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are looking to parameterize the configuration, so that you can dynamically pass the lakehouse name, following should work for you.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%%configure -f 
{
    "defaultLakehouse": { 
        "name": {
			"parameterName": "DefaultLakehouseName", 
			"defaultValue": "Raw_LH"
		},
        "id": {
			"parameterName": "LakehouseGUID", 
			"defaultValue": "23adfdsf-2safsdf-wwer"
		},
        "workspaceId": {
			"parameterName": "WorkspaceGUID", 
			"defaultValue": "adfase-2safsdf-wwer"
		}
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;And then you can pass parameters in notebook activity in Data pipeline:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="govindarajan_d_0-1737728647303.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1230692i93EF2DDDE35B360D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="govindarajan_d_0-1737728647303.png" alt="govindarajan_d_0-1737728647303.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check the following documentation as well:&amp;nbsp;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: SegoeUI, Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: SegoeUI, Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif;"&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/author-execute-notebook#parameterized-session-configuration-from-a-pipeline" target="_blank" rel="noopener"&gt;https://learn.microsoft.com/en-us/fabric/data-engineering/author-execute-notebook#parameterized-session-configuration-from-a-pipeline&lt;/A&gt;&lt;/P&gt;
&lt;P style="line-height: 1.71429; font-family: SegoeUI, Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Updating notebook definition for changing&lt;SPAN&gt;&amp;nbsp;lakehouse configuration dynamically would be too much work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 14:24:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4379048#M6470</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2025-01-24T14:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Update Notebook attached lakehouse using code</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4379350#M6481</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/803370"&gt;@chetanhiwale&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;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. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Niels&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 08:29:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4379350#M6481</guid>
      <dc:creator>ObungiNiels</dc:creator>
      <dc:date>2025-01-24T08:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Update Notebook attached lakehouse using code</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4382887#M6552</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/803370"&gt;@chetanhiwale&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thankyou&lt;SPAN&gt;&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/644992"&gt;@govindarajan_d&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/729364"&gt;@ObungiNiels&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;for taking time and providing solution.&lt;/P&gt;
&lt;P&gt;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.&lt;BR /&gt;If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Vinay Pabbu&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 16:50:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4382887#M6552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-27T16:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Update Notebook attached lakehouse using code</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4389455#M6745</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/644992"&gt;@govindarajan_d&lt;/a&gt;&amp;nbsp;&amp;nbsp;for helping me out here. The solution you provided really worked for me. Thanks again !!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 07:56:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Update-Notebook-attached-lakehouse-using-code/m-p/4389455#M6745</guid>
      <dc:creator>chetanhiwale</dc:creator>
      <dc:date>2025-01-31T07:56:28Z</dc:date>
    </item>
  </channel>
</rss>

