<?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: Access variable library in UDF in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873298#M13401</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/833530"&gt;@bruinsmm&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I ran into the same issue before — the Variable Library wasn’t showing up in the UDF connection manager. It turned out that I hadn’t actually added the variable library as a connection inside the UDF.&lt;/P&gt;&lt;P&gt;Here’s what worked for me:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Go to your workspace and make sure your &lt;STRONG&gt;Variable Library&lt;/STRONG&gt; is created and published.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;In your &lt;STRONG&gt;User Data Function&lt;/STRONG&gt;, open the &lt;STRONG&gt;Connection Manager&lt;/STRONG&gt; and click &lt;STRONG&gt;Add connection&lt;/STRONG&gt; → choose &lt;STRONG&gt;Variable Library&lt;/STRONG&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Select your variable library and give it an &lt;STRONG&gt;alias name&lt;/STRONG&gt; (for example, MyVarLibAlias).&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Use that same alias in your code:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;@udf.connection(argName="varLib", alias="MyVarLibAlias")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;The alias must match exactly what you gave in the connection manager.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;If you still don’t see the variable library in the list, try refreshing the UDF page or check that you have permission to access it in the workspace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once the connection is set up, your code should work fine — you’ll be able to read the variables using:&lt;/P&gt;&lt;P&gt;variables = varLib.getVariables()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Gopi Krishna&lt;/STRONG&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Wed, 12 Nov 2025 14:21:06 GMT</pubDate>
    <dc:creator>Ugk161610</dc:creator>
    <dc:date>2025-11-12T14:21:06Z</dc:date>
    <item>
      <title>Access variable library in UDF</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873191#M13400</link>
      <description>&lt;P&gt;Microsoft has published the following code to get the values of the variable library, but in UDF in the connection manager i cann't find a variable library to select them. What's do i'm wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;@udf.connection(argName="varLib", alias="&amp;lt;My Variable Library Alias&amp;gt;")&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;@udf.function()&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;def get_storage_path(dataset: str, varLib: fn.FabricVariablesClient) -&amp;gt; str:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;"""&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;Description: Determine storage path for a dataset based on environment configuration from Variable Library.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;Args:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;dataset_name (str): Name of the dataset to store.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;varLib (fn.FabricVariablesClient): Fabric Variable Library connection.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;Returns:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;str: Full storage path for the dataset.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;"""&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;# Retrieve variables from Variable Library&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;variables = varLib.getVariables()&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;# Get environment and base paths&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;env = variables.get("ENV") &lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;dev_path = variables.get("DEV_FILE_PATH")&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;prod_path = variables.get("PROD_FILE_PATH")&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;# Apply environment-specific logic&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;if env.lower() == "dev":&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;return f"{dev_path}{dataset}/"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;elif env.lower() == "prod":&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;return f"{prod_path}{dataset}/"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;else:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;return f"incorrect settings define for ENV variable"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2025 12:33:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873191#M13400</guid>
      <dc:creator>bruinsmm</dc:creator>
      <dc:date>2025-11-12T12:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Access variable library in UDF</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873298#M13401</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/833530"&gt;@bruinsmm&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I ran into the same issue before — the Variable Library wasn’t showing up in the UDF connection manager. It turned out that I hadn’t actually added the variable library as a connection inside the UDF.&lt;/P&gt;&lt;P&gt;Here’s what worked for me:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;Go to your workspace and make sure your &lt;STRONG&gt;Variable Library&lt;/STRONG&gt; is created and published.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;In your &lt;STRONG&gt;User Data Function&lt;/STRONG&gt;, open the &lt;STRONG&gt;Connection Manager&lt;/STRONG&gt; and click &lt;STRONG&gt;Add connection&lt;/STRONG&gt; → choose &lt;STRONG&gt;Variable Library&lt;/STRONG&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Select your variable library and give it an &lt;STRONG&gt;alias name&lt;/STRONG&gt; (for example, MyVarLibAlias).&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Use that same alias in your code:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;@udf.connection(argName="varLib", alias="MyVarLibAlias")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;The alias must match exactly what you gave in the connection manager.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;If you still don’t see the variable library in the list, try refreshing the UDF page or check that you have permission to access it in the workspace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once the connection is set up, your code should work fine — you’ll be able to read the variables using:&lt;/P&gt;&lt;P&gt;variables = varLib.getVariables()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Gopi Krishna&lt;/STRONG&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 12 Nov 2025 14:21:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873298#M13401</guid>
      <dc:creator>Ugk161610</dc:creator>
      <dc:date>2025-11-12T14:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Access variable library in UDF</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873336#M13402</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/833530"&gt;@bruinsmm&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Fabric, a UDF can read a Variable Library only after you both create a Manage connections entry that points at the Variable Library item and reference that connection’s alias in your @udf.connection(...) decorator. If you skip step 1, the Variable Library won’t appear in the UDF’s connection picker.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create the Variable Library item&lt;BR /&gt;Workspace &amp;gt; New &amp;gt; Variable library &amp;gt; add variables (e.g., ENV, DEV_FILE_PATH, PROD_FILE_PATH).&lt;BR /&gt;Docs: &lt;A href="https://learn.microsoft.com/en-us/fabric/cicd/variable-library/variable-library-overview" target="_blank" rel="noopener"&gt;Variable Library overview&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Create a workspace connection to that Variable Library&lt;BR /&gt;Workspace header &amp;gt; Manage connections &amp;gt; New connection &amp;gt; Fabric item &amp;gt; Variable library &amp;gt; pick your VL item &amp;gt; note the Alias&lt;BR /&gt;Docs: &lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/user-data-functions/connect-to-data-sources" target="_blank" rel="noopener"&gt;Connect to data sources for UDFs&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Reference the alias in your UDF code and use the correct type&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="markup"&gt;import fabric.functions as fn
from fabric.functions import udf

@udf.connection(argName="varLib", alias="MyVarLib")
@udf.function()
def get_storage_path(dataset: str, varLib: fn.FabricVariablesClient) -&amp;gt; str:
    variables = varLib.getVariables()
    env = (variables.get("ENV") or "").lower()
    dev_path  = variables.get("DEV_FILE_PATH") or ""
    prod_path = variables.get("PROD_FILE_PATH") or ""

    if env == "dev":
        return f"{dev_path}{dataset}/"
    elif env == "prod":
        return f"{prod_path}{dataset}/"
    else:
        return "incorrect settings defined for ENV variable"​&lt;/LI-CODE&gt;&lt;P&gt;4.&amp;nbsp;Publish the UDF, then open the UDF item and check the Connections pane. You should now see the Variable Library bound via the alias.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2025 14:42:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873336#M13402</guid>
      <dc:creator>tayloramy</dc:creator>
      <dc:date>2025-11-12T14:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Access variable library in UDF</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873390#M13404</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/920086"&gt;@Ugk161610&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i press the&amp;nbsp;&lt;STRONG&gt;Add connection&lt;/STRONG&gt; button in the UDF manager, i can only select the following items:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bruinsmm_0-1762960016582.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1309353iAD4FA3C720328B33/image-size/medium?v=v2&amp;amp;px=400" role="button" title="bruinsmm_0-1762960016582.png" alt="bruinsmm_0-1762960016582.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;when i refresh the UDF page, now i see the item Variable Library.&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Nov 2025 15:15:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Access-variable-library-in-UDF/m-p/4873390#M13404</guid>
      <dc:creator>bruinsmm</dc:creator>
      <dc:date>2025-11-12T15:15:21Z</dc:date>
    </item>
  </channel>
</rss>

