<?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: How to List and Execute Notebooks in Microsoft Fabric? in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/How-to-List-and-Execute-Notebooks-in-Microsoft-Fabric/m-p/4053573#M3192</link>
    <description>&lt;P&gt;1. Perhaps this will do the job, it also seems to list the notebooks in the workspace: &lt;A href="https://fabric.guru/one-line-code-to-get-a-list-of-items-from-all-the-fabricpremium-workspaces" target="_blank" rel="noopener"&gt;https://fabric.guru/one-line-code-to-get-a-list-of-items-from-all-the-fabricpremium-workspaces&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I think you can use some of the functions found here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/microsoft-spark-utilities#notebook-utilities" target="_blank" rel="noopener"&gt;https://learn.microsoft.com/en-us/fabric/data-engineering/microsoft-spark-utilities#notebook-utilities&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: this blog shows how to achieve both 1. and 2.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://fabric.guru/using-runmultiple-to-orchastrate-notebook-execution-in-microsoft-fabric" target="_blank" rel="noopener"&gt;https://fabric.guru/using-runmultiple-to-orchastrate-notebook-execution-in-microsoft-fabric&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To list all notebooks in the workspace:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import sempy.fabric as fabric&lt;/P&gt;&lt;P&gt;notebooks = fabric.list_items().query("Type == 'Notebook'")&lt;/P&gt;&lt;P&gt;noteboo&lt;SPAN&gt;ks&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jul 2024 09:43:37 GMT</pubDate>
    <dc:creator>frithjof_v</dc:creator>
    <dc:date>2024-07-22T09:43:37Z</dc:date>
    <item>
      <title>How to List and Execute Notebooks in Microsoft Fabric?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/How-to-List-and-Execute-Notebooks-in-Microsoft-Fabric/m-p/4053440#M3189</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm using Microsoft Fabric and need help managing notebooks in my workspace. Specifically:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;How to list notebooks&lt;/STRONG&gt; stored in various directories?&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;How to execute these notebooks&lt;/STRONG&gt; from a central notebook?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;My current function lists objects in lakehouses:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# List all objects in the root folder
root = mssparkutils.fs.ls("/")

for item in root:
    print(item.name)  # Print the name of the object

    # List all objects in the subfolder
    subitems = mssparkutils.fs.ls(item.path)
    for subitem in subitems:
        print("  " + subitem.name)  # Print the name of the subitem

        # List all objects in the subsubfolder
        subsubitems = mssparkutils.fs.ls(subitem.path)
        for subsubitem in subsubitems:
            print("    " + subsubitem.name)  # Print the name of the subsubitem&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this code doesn’t list my notebooks. Any guidance would be appreciated!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 08:14:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/How-to-List-and-Execute-Notebooks-in-Microsoft-Fabric/m-p/4053440#M3189</guid>
      <dc:creator>Nytar</dc:creator>
      <dc:date>2024-07-22T08:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to List and Execute Notebooks in Microsoft Fabric?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/How-to-List-and-Execute-Notebooks-in-Microsoft-Fabric/m-p/4053573#M3192</link>
      <description>&lt;P&gt;1. Perhaps this will do the job, it also seems to list the notebooks in the workspace: &lt;A href="https://fabric.guru/one-line-code-to-get-a-list-of-items-from-all-the-fabricpremium-workspaces" target="_blank" rel="noopener"&gt;https://fabric.guru/one-line-code-to-get-a-list-of-items-from-all-the-fabricpremium-workspaces&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I think you can use some of the functions found here:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/microsoft-spark-utilities#notebook-utilities" target="_blank" rel="noopener"&gt;https://learn.microsoft.com/en-us/fabric/data-engineering/microsoft-spark-utilities#notebook-utilities&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: this blog shows how to achieve both 1. and 2.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://fabric.guru/using-runmultiple-to-orchastrate-notebook-execution-in-microsoft-fabric" target="_blank" rel="noopener"&gt;https://fabric.guru/using-runmultiple-to-orchastrate-notebook-execution-in-microsoft-fabric&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To list all notebooks in the workspace:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import sempy.fabric as fabric&lt;/P&gt;&lt;P&gt;notebooks = fabric.list_items().query("Type == 'Notebook'")&lt;/P&gt;&lt;P&gt;noteboo&lt;SPAN&gt;ks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 09:43:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/How-to-List-and-Execute-Notebooks-in-Microsoft-Fabric/m-p/4053573#M3192</guid>
      <dc:creator>frithjof_v</dc:creator>
      <dc:date>2024-07-22T09:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to List and Execute Notebooks in Microsoft Fabric?</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/How-to-List-and-Execute-Notebooks-in-Microsoft-Fabric/m-p/4055516#M3206</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/778667"&gt;@Nytar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/437984"&gt;@frithjof_v&lt;/a&gt;&amp;nbsp;for your reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please execute the following code in notebook:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import requests

workspaceID = 'your_workspace_id'
api_url = f'https://api.fabric.microsoft.com/v1/workspaces/{workspaceID}/notebooks'
headers = {
   "Authorization": "Bearer your_token",
   "Content-Type": "application/json"
}

res = requests.get(api_url,headers=headers)
note = res.json().get("value",[])

for note in note:
    if note['type'] == 'Notebook':
        print(note['displayName'])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace workspaceid and your_token with your own.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result of the execution is shown below, which lists all the notebooks in my workspace.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_0-1721714684725.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1136927i5186782F9B6F904D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_0-1721714684725.png" alt="vhuijieymsft_0-1721714684725.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can click on this official document for more information about it:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/fabric/notebook/items/list-notebooks?tabs=HTTP" target="_blank"&gt;Items - List Notebooks - REST API (Notebook) | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any other questions please feel free to contact me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 06:05:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/How-to-List-and-Execute-Notebooks-in-Microsoft-Fabric/m-p/4055516#M3206</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-23T06:05:50Z</dc:date>
    </item>
  </channel>
</rss>

