Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MangoMagic
Regular Visitor

VS Code Fabric User Data Functions

I was trying to develop Fabric User Data Functions on my local machine as doing it through Fabric portal is very difficult and it takes many minutes to publish / test & debug function after making minor changes.

 

I installed all the VS Code extensions and also Azure Core Tools:

MangoMagic_0-1752243590281.png

But when I try and build the function it doesn't work ☹️, it can't find functions module in the fabric package:

MangoMagic_1-1752243708926.png

I tried installing fabric module using following command in terminal:

python -m pip install fabric

But functions module is still missing.

 

Does anyone know how to resolve this issue and dev/test functions in VS Code?

 

1 ACCEPTED SOLUTION
v-dineshya
Community Support
Community Support

Hi @MangoMagic ,

Thank you for reaching out to the Microsoft Community Forum.

 

You are trying to import "fabric.functions", which is not part of the open-source fabric PyPI package. In Microsoft Fabric, User Defined Functions (UDFs) for the Data Factory or Lakehouse experience are powered through a special runtime in the Fabric service not a publicly installable Python package like fabric.functions.

 

So when you try to import

 

import fabric.functions as fn

 

You are assuming that "fabric.functions" is an importable local module but it's only available in the Microsoft Fabric runtime environment, not on your local machine.


1. Microsoft Fabric UDFs rely on a specific SDK that is not publicly available via PyPI. It's bundled within the Fabric runtime environment. You cannot run or test these functions locally using the standard Python environment.You must use the Fabric portal or a supported development environment that includes the Fabric runtime.

 

2. You can test the fabric.functions module locally by creating a sample module with the same interface for testing purposes. Alternatively, use logging and unit tests to validate your logic independently of the Fabric-specific decorators.

 

Please refer Microsoft document

Microsoft Fabric documentation - Microsoft Fabric | Microsoft Learn

 

I hope this information helps. Please do let us know if you have any further queries.

 

Regards,

Dinesh

View solution in original post

7 REPLIES 7
BhaveshPatel
Community Champion
Community Champion

Hi @MangoMagic 

 

Why you develop the fabric user functions on premises? Gone are the day when we were developing everything on premises. Now it is time to develop everything online ( whether Fabric SQL, Semantic Data Model, or User Functions. 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.
v-dineshya
Community Support
Community Support

Hi @MangoMagic ,

Thank you for reaching out to the Microsoft Community Forum.

 

You are trying to import "fabric.functions", which is not part of the open-source fabric PyPI package. In Microsoft Fabric, User Defined Functions (UDFs) for the Data Factory or Lakehouse experience are powered through a special runtime in the Fabric service not a publicly installable Python package like fabric.functions.

 

So when you try to import

 

import fabric.functions as fn

 

You are assuming that "fabric.functions" is an importable local module but it's only available in the Microsoft Fabric runtime environment, not on your local machine.


1. Microsoft Fabric UDFs rely on a specific SDK that is not publicly available via PyPI. It's bundled within the Fabric runtime environment. You cannot run or test these functions locally using the standard Python environment.You must use the Fabric portal or a supported development environment that includes the Fabric runtime.

 

2. You can test the fabric.functions module locally by creating a sample module with the same interface for testing purposes. Alternatively, use logging and unit tests to validate your logic independently of the Fabric-specific decorators.

 

Please refer Microsoft document

Microsoft Fabric documentation - Microsoft Fabric | Microsoft Learn

 

I hope this information helps. Please do let us know if you have any further queries.

 

Regards,

Dinesh

I have the same issue. But the difference is that I am trying to do this on the Fabric UI directly and I do get the same "ModuleNotFoundError" even though the fabric-user-data-functions is part of my environment

Hi @Migangtor ,

Thank you for reaching out to the Microsoft Community Forum.

 

Please try below steps to fix the issue.

 

1. Re-publish the UDF item,

Open the UDF item --> Library management. Confirm fabric_user_data_functions is present, it should be and is non-removable. Click Publish to ensure the runtime actually picks the listed versions.


2. Replace your code temporarily with the below sample to isolate the error:

 

from datetime import datetime
import logging
import fabric.functions as fn

udf = fn.UserDataFunctions()

@udf.function()
def hello_fabric(name: str) -> str:
logging.info("Python UDF trigger function processed a request.")
return f"Welcome to Fabric Functions, {name}, at {datetime.now()}!"

 

Note: if this fails, it’s not your logic. it’s the runtime/library binding.

 

3. Run the function from portal or an invocation and then open View logs for the UDF item. Look for the exact stack and the runtime version being used. UDF doc set shows the logging approach; portal has a logs view for UDF runs.

 

4. Remove any conflicting library entries, If you previously added fabric the SSH/task-runner package at the UDF item or workspace, remove it. it doesn’t contain fabric.functions and can cause confusion. The correct SDK is fabric_user_data_functions.

 

5. Recreate the UDF item, from VS Code (Fabric Workspace explorer), create a new UDF item, choose Python 3.11, open locally, and publish. This resets the item with a clean configuration and the right SDK. The Quickstart/Marketplace pages document the exact flow, including local run and publish.

 

Please refer below links.

Quickstart - Create a Fabric User data functions item in Visual Studio Code - Microsoft Fabric | Mic...

fabric.functions package | Microsoft Learn

Python programming model for Fabric User data functions - Microsoft Fabric | Microsoft Learn

How to manage libraries for your Fabric User Data Functions - Microsoft Fabric | Microsoft Learn

 

I hope this information helps. Please do let us know if you have any further queries.

 

Regards,

Dinesh

Hi @MangoMagic ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Regards,

Dinesh

Hi @MangoMagic ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Regards,

Dinesh

Hi @MangoMagic ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet. And, if you have any further query do let us know.

 

Regards,

Dinesh

Helpful resources

Announcements
December Fabric Update Carousel

Fabric Monthly Update - December 2025

Check out the December 2025 Fabric Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.