<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Fabric CLI on datarune.online</title>
        <link>https://datarune.online/tags/fabric-cli/</link>
        <description>Recent content in Fabric CLI on datarune.online</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language>
        <lastBuildDate>Sun, 07 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://datarune.online/tags/fabric-cli/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Automate updating the icon in Microsoft Fabric workspaces using Fabric CLI</title>
        <link>https://datarune.online/p/automate-updating-the-icon-in-microsoft-fabric-workspaces-using-fabric-cli/</link>
        <pubDate>Sun, 07 Jun 2026 00:00:00 +0000</pubDate>
        
        <guid>https://datarune.online/p/automate-updating-the-icon-in-microsoft-fabric-workspaces-using-fabric-cli/</guid>
        <description>&lt;img src="https://datarune.online/img/ws-icon-update.webp" alt="Featured image of post Automate updating the icon in Microsoft Fabric workspaces using Fabric CLI" /&gt;&lt;h1 id=&#34;-disclaimer-&#34;&gt;⚠️ DISCLAIMER ⚠️
&lt;/h1&gt;&lt;p&gt;To update the workspace icon in Microsoft Fabric currently the only way is to call an undocumented REST API. Since it is undocumented it can be changed without notice at any time by Microsoft, so use this information and code at your own risk.&lt;/p&gt;
&lt;h1 id=&#34;how-this-came-about&#34;&gt;How this came about&amp;hellip;
&lt;/h1&gt;&lt;p&gt;Last year at the Microsoft Fabric Community Conference in Las Vegas (FABCON) in March 2025 I attended a session with &lt;a class=&#34;link&#34; href=&#34;https://www.linkedin.com/in/erwindekreuk/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Erwin de Kreuk&lt;/a&gt; and &lt;a class=&#34;link&#34; href=&#34;https://linkedin.com/in/groennerup/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Peer Grønnerup&lt;/a&gt; where they among other topics talked about automating different aspects of Microsoft Fabric. Peer showed a demo where he used a Notebook on how to update icons for the workspaces based on different filtering criteria. He had also written &lt;a class=&#34;link&#34; href=&#34;https://peerinsights.emono.dk/automating-fabric-maintaining-workspace-icon-images&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;a blog post&lt;/a&gt; on this topic and his notebook &lt;a class=&#34;link&#34; href=&#34;https://github.com/gronnerup/Fabric/tree/main/AutomatingFabric/Notebooks&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;can be found here&lt;/a&gt;. Rather cool, I thought 🤩&lt;/p&gt;
&lt;p&gt;All well and good, and after while I did not think so much more about it&amp;hellip;until I recently decided to include the Fabric CLI in &lt;a class=&#34;link&#34; href=&#34;https://datarune.online/p/microsoft-fabric-rest-api-coverage-analysis/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;my coverage analysis of available tools calling the Microsoft Fabric REST API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I remembered the possibilty that Peer had talked about and wondered&amp;hellip;would it be possible to use the &lt;code&gt;fab api&lt;/code&gt; command to do the same?&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s see&amp;hellip;&lt;/p&gt;
&lt;h1 id=&#34;exploring-the-fab-api-command&#34;&gt;Exploring the &lt;code&gt;fab api&lt;/code&gt; command
&lt;/h1&gt;&lt;p&gt;The default for Fabric CLI is to use the Fabric REST API. When using the &lt;code&gt;fab api&lt;/code&gt; command you can extend it to use other APIs and currently it is limited to 3 other APIs (a.k.a audiences):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Power BI → &lt;code&gt;api.powerbi.com/v1.0/myorg&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Azure → &lt;code&gt;management.azure.com&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Storage → OneLake DFS&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What if we could use the Power BI audience switch (&lt;code&gt;-A powerbi&lt;/code&gt;) to call this undocumented API and get the workspace icon updated?&lt;br&gt;
I had a look at Peer&amp;rsquo;s Notebook code and the endpoint he calls to update an icon is &lt;code&gt;https://{cluster_base_url}metadata/folders/{workspace_id}&lt;/code&gt; where the variable &lt;code&gt;cluster_base_uri&lt;/code&gt; in his code is a subset of the &lt;code&gt;@odata.context&lt;/code&gt; field returned when you call the endpoint &lt;code&gt;https://api.powerbi.com/v1.0/myorg/capacities&lt;/code&gt;. I saw some examples values of the cluster URI and it was nothing like the endpoints supported by Fabric CLI [sad trombone] 😞&lt;/p&gt;
&lt;p&gt;But hey, let&amp;rsquo;s try anyways and see what we get when fetching data from the endpoint. Let&amp;rsquo;s go 🚀&lt;/p&gt;
&lt;p&gt;Lo and behold, when calling the &lt;code&gt;GET https://api.powerbi.com/v1.0/myorg/capacities&lt;/code&gt; equivalent in Fabric CLI → &lt;code&gt;fab api capacities -A powerbi&lt;/code&gt;, it returns this value in the &lt;code&gt;@odata.context&lt;/code&gt; field → &lt;code&gt;https://api.powerbi.com/v1.0/myorg/$metadata#capacities&lt;/code&gt;, meaning this is an API which is supported but first we have to tweak it just a little bit.&lt;/p&gt;
&lt;h2 id=&#34;why-this-will-work&#34;&gt;Why this will work
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;code&gt;fab api -A powerbi&lt;/code&gt; builds under → &lt;code&gt;https://api.powerbi.com/v1.0/myorg/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The endpoint that allows us to work with workspace icons is → &lt;code&gt;https://api.powerbi.com/metadata/folders/{workspaceId}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;../../metadata/folders/{workspaceId}&lt;/code&gt; to move from &lt;code&gt;/v1.0/myorg/&lt;/code&gt; back to the host root → &lt;code&gt;fab api -A powerbi &amp;quot;../../metadata/folders/{workspaceId}&amp;quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Which then will resolve to → &lt;code&gt;https://api.powerbi.com/metadata/folders/{workspaceId}&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h1 id=&#34;requirements&#34;&gt;Requirements
&lt;/h1&gt;&lt;ol&gt;
&lt;li&gt;The endpoint only supports interactive user authentication and as a result it cannot be used for unattended automation with service principals&lt;/li&gt;
&lt;li&gt;You need to have Workspace Admin permissions on the target workspace&lt;/li&gt;
&lt;li&gt;The endpoint only supports PNG and JPG files and files cannot be larger than 45KB&lt;/li&gt;
&lt;/ol&gt;
&lt;h1 id=&#34;step-by-step-updating-a-workspace-icon&#34;&gt;Step by step updating a workspace icon
&lt;/h1&gt;&lt;h2 id=&#34;step-0&#34;&gt;Step 0.
&lt;/h2&gt;&lt;p&gt;If you have not installed Fabric CLI yet, follow the instructions &lt;a class=&#34;link&#34; href=&#34;https://microsoft.github.io/fabric-cli/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;in the docs&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;step-1---authenticate&#34;&gt;Step 1 - Authenticate
&lt;/h2&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;fab auth login
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;step-2---set-variables&#34;&gt;Step 2 - Set variables
&lt;/h2&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;WORKSPACE_ID&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;lt;workspace-id&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ICON_PATH&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;./workspace-icon.png&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;step-3-prepare-your-icon-payload&#34;&gt;Step 3. Prepare your icon payload
&lt;/h2&gt;&lt;p&gt;The endpoint expects the &lt;code&gt;icon&lt;/code&gt; field to contain a PNG or JPG data URI. If your icon is SVG or another format, convert it to PNG first.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;python3 -c &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;import base64,json,os; p=os.environ[&amp;#34;ICON_PATH&amp;#34;]; b=base64.b64encode(open(p,&amp;#34;rb&amp;#34;).read()).decode(); print(json.dumps({&amp;#34;icon&amp;#34;:&amp;#34;data:image/png;base64,&amp;#34;+b}))&amp;#39;&lt;/span&gt; &amp;gt; workspace-icon-payload.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;Depending on how your Python config is set up you either use python or python3&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&#34;step-4---upload-or-replace-the-icon&#34;&gt;Step 4 - Upload or replace the icon
&lt;/h2&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;fab api -A powerbi -X put &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;../../metadata/folders/&lt;/span&gt;$WORKSPACE_ID&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt; -i workspace-icon-payload.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id=&#34;step-by-step-removing-a-custom-icon&#34;&gt;Step by step removing a custom Icon
&lt;/h1&gt;&lt;p&gt;Follow step 1 and 2 as above&lt;/p&gt;
&lt;h2 id=&#34;step-3b---prepare-a-reset-payload&#34;&gt;Step 3b - Prepare a reset payload
&lt;/h2&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;printf &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;{&amp;#34;icon&amp;#34;:&amp;#34;&amp;#34;}\n&amp;#39;&lt;/span&gt; &amp;gt; workspace-icon-delete-payload.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;step-4b---updating-the-workspace-with-reset-payload&#34;&gt;Step 4b - Updating the workspace with reset payload
&lt;/h2&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;fab api -A powerbi -X put &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;../../metadata/folders/&lt;/span&gt;$WORKSPACE_ID&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt; -i workspace-icon-delete-payload.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id=&#34;what-if-i-don-want-to-hack-these-commands-one-by-one-but-rather-run-a-script&#34;&gt;What if I don&amp;rsquo; want to hack these commands one by one, but rather run a script?
&lt;/h1&gt;&lt;h2 id=&#34;ive-got-you&#34;&gt;I&amp;rsquo;ve got you!
&lt;/h2&gt;&lt;p&gt;I have gotten a Python script built taking the workspace-id and icon path as parameters.&lt;br&gt;
In addition it currently supports:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Workspace name (if you don&amp;rsquo;t have/want to use the workspace id)&lt;/li&gt;
&lt;li&gt;Update several workspaces based on tag memberships&lt;/li&gt;
&lt;li&gt;Update several workspaces based on matching string&lt;/li&gt;
&lt;li&gt;Converts automatically your svg file to png (installation of the free ImageMagick or cairosvg required)&lt;/li&gt;
&lt;li&gt;Convert automatically other image files to png (installation of the free ImageMagick required)&lt;/li&gt;
&lt;li&gt;A delete icon switch which supports both single and multiple matching workspaces&lt;/li&gt;
&lt;li&gt;A dry-run switch that shows you what will be done without performing the actual update/delete&lt;/li&gt;
&lt;li&gt;A inspect-only switch that returns the output from calling the workspace metadata endpoint&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I have put the script in my (new) public repo for Microsoft Fabric helper scripts and &lt;a class=&#34;link&#34; href=&#34;https://github.com/datarune-online/fabric-helper-scripts/tree/main/update-workspace-icon&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;you can find it here&lt;/a&gt;. You are free to come with suggestions/issues or feedback on how the can become an even better helper script. If you feel comfortable making changes/additions to it feels free to send a PR.&lt;/p&gt;
&lt;h1 id=&#34;ending-words&#34;&gt;Ending words
&lt;/h1&gt;&lt;p&gt;This was a fun exercise for me and a workaround we can all partake to visually make our different workspaces stand out.&lt;br&gt;
We can then only hope Microsoft at some point will take it to heart that this is something we want an official REST API for and preferably with service principal support 🤞&lt;/p&gt;
&lt;p&gt;I hope you enjoyed this article, cause I for sure had fun exploring this 😅&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
