UserDataFunctions Class

This class is necessary to define User Data Functions in Fabric. Please ensure an instantiation of this class exists in your code before any User Data Functions are defined.

Constructor

UserDataFunctions()

Remarks

This class is used to define User Data Functions in Fabric. The class must be instantiated before any User Data Functions are defined. The instantiation of this class is required.

Methods

alias_connection

This decorator is used to tell a User Data Function that there is a connection to a data source. This decorator must be used in tandem with a parameter of type FabricSqlConnection or FabricLakehouseClient (see the example under Remarks).

connection

This decorator is used to tell a User Data Function that there is a connection to a data source. This decorator must be used in tandem with a parameter of type FabricSqlConnection or FabricLakehouseClient (see the example under Remarks).

context

This decorator is used to tell a User Data Function that there is a UserDataFunctionContext parameter. This decorator must be used in tandem with a parameter of type UserDataFunctionContext.

fabric_item_input

This decorator is deprecated. Please use connection instead. Note the alias parameter in connection is now the first parameter.

function

This decorator is used to define a User Data Function in Fabric. The function must be decorated with this decorator in order to be recognized as a User Data Function.

generic_connection

This decorator is used to tell a User Data Function that there is a connection to a data source. This decorator must be used in tandem with a parameter of type FabricSqlConnection or FabricLakehouseClient (see the example under Remarks).

get_udf_oai_spec
register_needed_modules

Register needed modules for the specified audience type.

If the audience type is 'CosmosDB', the CosmosDB module will be imported. If the audience type is 'KeyVault', the KeyVault module will be imported.

More will be added as needed.

register_provider
streaming_function

Define a streaming User Data Function whose HTTP response is flushed to the caller incrementally instead of being buffered into a single body.

The decorated function must return a StreamResponse wrapping an iterator (sync or async) of bytes/str chunks. Each chunk is streamed to the client as it is produced — enabling true end-to-end HTTP streaming (e.g. relaying an Apache Arrow stream from Power BI executeDaxQueries).

Important

Streaming uses the Azure Functions HTTP streams feature and

requires the azurefunctions-extensions-http-fastapi package in

your requirements.txt plus the app setting

PYTHON_ENABLE_INIT_INDEXING=1. When a streaming function is

present the app runs in ASGI mode app-wide, so it cannot also host

classic (buffered) @udf.function() functions in the same app.

user_data_function_context_input

This decorator is deprecated. Please use context instead.

alias_connection

This decorator is used to tell a User Data Function that there is a connection to a data source. This decorator must be used in tandem with a parameter of type FabricSqlConnection or FabricLakehouseClient (see the example under Remarks).

alias_connection(alias: str, argName: str | None = None, **kwargs) -> Callable[[...], Any]

Parameters

Name Description
alias
Required
str

The alias of the data connection that is being used.

argName
str

The name of the parameter in the function signature. If not provided, the alias will be used.

Default value: None

connection

This decorator is used to tell a User Data Function that there is a connection to a data source. This decorator must be used in tandem with a parameter of type FabricSqlConnection or FabricLakehouseClient (see the example under Remarks).

connection(alias: str | None = None, argName: str | None = None, **kwargs) -> Callable[[...], Any]

Parameters

Name Description
alias
str

The alias of the data connection that is being used.

Default value: None
argName
str

The name of the parameter in the function signature. If not provided, the alias will be used.

Default value: None

context

This decorator is used to tell a User Data Function that there is a UserDataFunctionContext parameter. This decorator must be used in tandem with a parameter of type UserDataFunctionContext.

context(argName, **kwargs) -> Callable[[...], Any]

Parameters

Name Description
argName
Required
str

The name of the parameter in the function signature.

fabric_item_input

This decorator is deprecated. Please use connection instead. Note the alias parameter in connection is now the first parameter.

fabric_item_input(argName, alias: str, **kwargs) -> Callable[[...], Any]

Parameters

Name Description
argName
Required
alias
Required

function

This decorator is used to define a User Data Function in Fabric. The function must be decorated with this decorator in order to be recognized as a User Data Function.

function(name=None)

Parameters

Name Description
name
str

The name of the function. This parameter is not used in the current version of Fabric.

Default value: None

generic_connection

This decorator is used to tell a User Data Function that there is a connection to a data source. This decorator must be used in tandem with a parameter of type FabricSqlConnection or FabricLakehouseClient (see the example under Remarks).

generic_connection(argName: str, **kwargs) -> Callable[[...], Any]

Parameters

Name Description
audienceType
Required
str

The audience type of the data connection that is being used.

argName
Required
str

The name of the parameter in the function signature. If not provided, the audience type will be used.

get_udf_oai_spec

get_udf_oai_spec(publicUrl: str, privateFunctions: list, specFormat: str = 'yaml') -> str

Parameters

Name Description
publicUrl
Required
privateFunctions
Required
specFormat
Default value: yaml

register_needed_modules

Register needed modules for the specified audience type.

If the audience type is 'CosmosDB', the CosmosDB module will be imported. If the audience type is 'KeyVault', the KeyVault module will be imported.

More will be added as needed.

register_needed_modules(audienceType: str)

Parameters

Name Description
audienceType
Required

register_provider

register_provider(type: Type, provider: Type)

Parameters

Name Description
type
Required
provider
Required

streaming_function

Define a streaming User Data Function whose HTTP response is flushed to the caller incrementally instead of being buffered into a single body.

The decorated function must return a StreamResponse wrapping an iterator (sync or async) of bytes/str chunks. Each chunk is streamed to the client as it is produced — enabling true end-to-end HTTP streaming (e.g. relaying an Apache Arrow stream from Power BI executeDaxQueries).

Important

Streaming uses the Azure Functions HTTP streams feature and

requires the azurefunctions-extensions-http-fastapi package in

your requirements.txt plus the app setting

PYTHON_ENABLE_INIT_INDEXING=1. When a streaming function is

present the app runs in ASGI mode app-wide, so it cannot also host

classic (buffered) @udf.function() functions in the same app.

streaming_function(name=None)

Parameters

Name Description
name
str

Optional function/route name. Defaults to the function name.

Default value: None

user_data_function_context_input

This decorator is deprecated. Please use context instead.

user_data_function_context_input(argName, **kwargs) -> Callable[[...], Any]

Parameters

Name Description
argName
Required