<?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: call function in user data functions in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885827#M13702</link>
    <description>&lt;P&gt;use this code (tested &amp;amp; working):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import datetime
import fabric.functions as fn
import logging

udf = fn.UserDataFunctions()

async def get_environment_local(varLib: fn.FabricVariablesClient) -&amp;gt; str:
    variables = varLib.getVariables()   # sync call
    return variables["omgeving"]

async def get_result_local(varLib: fn.FabricVariablesClient) -&amp;gt; str:
    return await get_environment_local(varLib)

@udf.connection(argName="varLib", alias="varlib")
@udf.function()
async def hello_fabric(name: str, varLib: fn.FabricVariablesClient) -&amp;gt; str:
    logging.info("Running hello_fabric")

    omgeving = await get_result_local(varLib)

    return (
        f"Welcome to Fabric Functions, {name}. "
        f"Omgeving: {omgeving}. "
        f"Time: {datetime.datetime.now()}"
    )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;When a function has @udf.function(), it becomes a remote Fabric function, not a normal Python function. Calling it directly (await get_environment(varLib)) bypasses Fabric's runtime, so the injected connection becomes None, and Fabric later tries to access None.headers, causing the NoneType error. Make helper functions local (not decorated) so they behave like real Python functions.&lt;BR /&gt;&lt;BR /&gt;Therefore I modified the code to &lt;STRONG&gt;remove the @udf.function() decorators from the helper functions and turn them into normal local Python functions&lt;/STRONG&gt;, so they no longer get wrapped by the Fabric runtime and can be safely called from inside the main UDF with a valid varLib connection.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Nov 2025 20:51:42 GMT</pubDate>
    <dc:creator>OnurOz</dc:creator>
    <dc:date>2025-11-25T20:51:42Z</dc:date>
    <item>
      <title>call function in user data functions</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885437#M13691</link>
      <description>&lt;P&gt;i have the following code in user data functions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;@udf.connection(argName="varLib", alias="varlib")&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;@udf.function()&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;async def get_environment(varLib: fn.FabricVariablesClient) -&amp;gt; str:&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; variables = varLib.getVariables()&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; omgeving = variables["omgeving"]&lt;/STRONG&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; return omgeving&lt;/STRONG&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;@udf.function()&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;async def get_result() -&amp;gt; str:&lt;/STRONG&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; result = get_environment()&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; return result&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when i call the function get_environment function via function get_result , i got the following message:&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;coroutine object get_environment at 0x78c6d405c880&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can i get the the right one result.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2025 12:34:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885437#M13691</guid>
      <dc:creator>bruinsmm</dc:creator>
      <dc:date>2025-11-25T12:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: call function in user data functions</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885496#M13693</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;BR /&gt;&lt;BR /&gt;&lt;EM&gt;(Edited my reply to fix the code, due the error mentioned &lt;A href="https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885507/highlight/true#M13695" target="_self"&gt;here&lt;/A&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;To get the correct value, modify get_result so it awaits get_environment. In Python with async/await, this means:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;@udf.connection(argName="varLib", alias="varlib")
@udf.function()
async def get_environment(varLib: fn.FabricVariablesClient) -&amp;gt; str:
    variables = varLib.getVariables()
    omgeving = variables["omgeving"]
    return omgeving


@udf.function()
async def get_result() -&amp;gt; str:
    result = await get_environment(varLib)   # &amp;lt;--- FIX
    return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;Onur&lt;/P&gt;&lt;DIV&gt;&lt;HR /&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;If this post helped you, feel free to give it some &lt;STRONG&gt;Kudos&lt;/STRONG&gt;! &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;And if it answered your question, please mark it as the &lt;EM&gt;accepted solution&lt;/EM&gt;.&lt;/P&gt;&lt;HR /&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Nov 2025 14:30:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885496#M13693</guid>
      <dc:creator>OnurOz</dc:creator>
      <dc:date>2025-11-25T14:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: call function in user data functions</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885507#M13695</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1355677"&gt;@OnurOz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've try your solution, but it don't work, i got the error message:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AttributeError: 'NoneType' object has no attribute 'headers'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think the problem is in the call function without VarLib parameter:&amp;nbsp;&lt;FONT color="#FF6600"&gt;&lt;SPAN&gt;get_environment()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;@udf&lt;/SPAN&gt;&lt;SPAN&gt;.connection(argName=&lt;/SPAN&gt;&lt;SPAN&gt;"varLib"&lt;/SPAN&gt;&lt;SPAN&gt;, alias=&lt;/SPAN&gt;&lt;SPAN&gt;"varlib"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;@udf&lt;/SPAN&gt;&lt;SPAN&gt;.function()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;async&lt;/SPAN&gt; &lt;SPAN&gt;def&lt;/SPAN&gt;&lt;SPAN&gt; get_environment(&lt;FONT color="#FF6600"&gt;varLib: fn.FabricVariablesClient&lt;/FONT&gt;) -&amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;str&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; variables = varLib.getVariables()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; omgeving = variables[&lt;/SPAN&gt;&lt;SPAN&gt;"omgeving"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; omgeving&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;@udf&lt;/SPAN&gt;&lt;SPAN&gt;.function()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;async&lt;/SPAN&gt; &lt;SPAN&gt;def&lt;/SPAN&gt;&lt;SPAN&gt; get_result() -&amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;str&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; result = &lt;/SPAN&gt;&lt;SPAN&gt;await&lt;/SPAN&gt;&lt;SPAN&gt; get_environment() &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# &amp;lt;-- await it&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; result&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Nov 2025 13:46:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885507#M13695</guid>
      <dc:creator>bruinsmm</dc:creator>
      <dc:date>2025-11-25T13:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: call function in user data functions</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885552#M13697</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;Yes, you will need to pass in a valid varLib object as a parameter to the get_environment call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&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;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2025 14:16:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885552#M13697</guid>
      <dc:creator>tayloramy</dc:creator>
      <dc:date>2025-11-25T14:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: call function in user data functions</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885557#M13698</link>
      <description>&lt;P&gt;sorry my bad, I've forgotten to add varlib to the call get_environment(), following code should do the work:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;@udf.function()
@udf.connection(argName="varLib", alias="varlib")
async def get_environment(varLib: fn.FabricVariablesClient) -&amp;gt; str:
    variables = varLib.getVariables()
    return variables["omgeving"]


@udf.function()
@udf.connection(argName="varLib", alias="varlib")
async def get_result(varLib: fn.FabricVariablesClient) -&amp;gt; str:
    result = await get_environment(varLib)   # I've forgotten this
    return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2025 14:20:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885557#M13698</guid>
      <dc:creator>OnurOz</dc:creator>
      <dc:date>2025-11-25T14:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: call function in user data functions</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885577#M13699</link>
      <description>&lt;P&gt;I have try the code. It don't work :&lt;span class="lia-unicode-emoji" title=":frowning_face:"&gt;☹️&lt;/span&gt;&lt;/P&gt;&lt;P&gt;got the same error message:&amp;nbsp;"error_message": "'NoneType' object has no attribute 'headers'"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;@udf.connection(argName="varLib", alias="varlib")&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;@udf.function()&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;async def get_environment(varLib: fn.FabricVariablesClient) -&amp;gt; str:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; variables = varLib.getVariables()&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; return variables["omgeving"]&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;@udf.connection(argName="varLib", alias="varlib")&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;@udf.function()&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;async def get_result(varLib: fn.FabricVariablesClient) -&amp;gt; str:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; result = await get_environment(varLib) &amp;nbsp; # I've forgotten this&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; return result&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 25 Nov 2025 14:43:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885577#M13699</guid>
      <dc:creator>bruinsmm</dc:creator>
      <dc:date>2025-11-25T14:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: call function in user data functions</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885827#M13702</link>
      <description>&lt;P&gt;use this code (tested &amp;amp; working):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import datetime
import fabric.functions as fn
import logging

udf = fn.UserDataFunctions()

async def get_environment_local(varLib: fn.FabricVariablesClient) -&amp;gt; str:
    variables = varLib.getVariables()   # sync call
    return variables["omgeving"]

async def get_result_local(varLib: fn.FabricVariablesClient) -&amp;gt; str:
    return await get_environment_local(varLib)

@udf.connection(argName="varLib", alias="varlib")
@udf.function()
async def hello_fabric(name: str, varLib: fn.FabricVariablesClient) -&amp;gt; str:
    logging.info("Running hello_fabric")

    omgeving = await get_result_local(varLib)

    return (
        f"Welcome to Fabric Functions, {name}. "
        f"Omgeving: {omgeving}. "
        f"Time: {datetime.datetime.now()}"
    )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;When a function has @udf.function(), it becomes a remote Fabric function, not a normal Python function. Calling it directly (await get_environment(varLib)) bypasses Fabric's runtime, so the injected connection becomes None, and Fabric later tries to access None.headers, causing the NoneType error. Make helper functions local (not decorated) so they behave like real Python functions.&lt;BR /&gt;&lt;BR /&gt;Therefore I modified the code to &lt;STRONG&gt;remove the @udf.function() decorators from the helper functions and turn them into normal local Python functions&lt;/STRONG&gt;, so they no longer get wrapped by the Fabric runtime and can be safely called from inside the main UDF with a valid varLib connection.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2025 20:51:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4885827#M13702</guid>
      <dc:creator>OnurOz</dc:creator>
      <dc:date>2025-11-25T20:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: call function in user data functions</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4886629#M13712</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1355677"&gt;@OnurOz&lt;/a&gt;&amp;nbsp;I have tried your code. It works!!. Thanks for your help and explanation about decorators.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2025 12:40:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/call-function-in-user-data-functions/m-p/4886629#M13712</guid>
      <dc:creator>bruinsmm</dc:creator>
      <dc:date>2025-11-26T12:40:42Z</dc:date>
    </item>
  </channel>
</rss>

