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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

conxu-ms

Utilize User Data Functions in Data pipelines with the Functions activity (Preview)

User Data Functions are now available in preview within data pipeline’s functions activity! This exciting new feature is designed to significantly enhance your data processing capabilities by allowing you to create and manage custom functions tailored to your specific needs.

What is a functions activity?

The functions activity in data pipelines is a powerful tool designed to enhance data processing capabilities by allowing you to execute custom logic and calculations within your data pipelines.

Data_pipeline_Functions_activity_named_My_UDF_FunctionData_pipeline_Functions_activity_named_My_UDF_Function

What is a User Data Functions item?

The User Data Functions item is a Fabric-native artifact that holds a collection of individual functions that share the same code file and configuration settings. You’ll also be able to access the Fabric resources available in your Workspace and any other ones that you have access to.

To learn more, check out the What is Fabric User data functions (Preview)? documentation.

Using User Data Functions in your Data pipeline

Step 1: Create a workspace

First, you’ll need a Fabric workspace to get started. You can follow the steps in this tutorial to Create a workspace in Microsoft Fabric.

Step 2: Create a User Data Function Item

Once you have a workspace, select the '+ New Item' button at the top left of your workspace.

New_item_button_in_Fabric_workspaceNew_item_button_in_Fabric_workspace

Select the 'User data functions (Preview)' item under the Develop data group towards the bottom of the New item list.

User_data_functions_preview_item_in_Fabric_s_new_item_listUser_data_functions_preview_item_in_Fabric_s_new_item_list

Name your User Data Functions item and select the 'Create' button.

Create_a_new_User_data_functions_item_with_an_option_to_name_your_item_and_eitheCreate_a_new_User_data_functions_item_with_an_option_to_name_your_item_and_eithe

Step 3: Create your functions in the User Data Functions item

Once your User Data Function loads, select the 'New function' button that populates at the center of the screen to get started on creating your functions.

Create_a_new_sample_function_buttonCreate_a_new_sample_function_button

By selecting the 'New function' button at the center of your screen, a sample “hello_fabric” function will automatically populate. For the purpose of this tutorial, we’ll just use this sample function that will take in a parameter of name. The function will display a welcome message that uses the name parameter alongside the current date/time.

User_data_functions_Functions_explorer_Functions_pane_that_displays_the_hello_faUser_data_functions_Functions_explorer_Functions_pane_that_displays_the_hello_fa

Optional

You can create/edit/remove any additional functions you’d like in the functions pane. If you are interested in learning more about User Data Functions, check out this previous post on Getting started with the User Data Functions item.

Step 4: Publish your function(s)

Select the 'Publish' button at the top right of the navigation bar to publish your User Data Functions so that the functions you just created can be referenced in your Fabric workspace.

Publish_button_inside_of_the_User_Data_Functions_editorPublish_button_inside_of_the_User_Data_Functions_editor

After a moment, you should see a banner populate at the top right of your screen that confirms the publish has succeeded.

A_banner_that_confirms_the_User_Data_Function_published_successfullyA_banner_that_confirms_the_User_Data_Function_published_successfully

Step 5: Create a Data pipeline with a functions activity

Navigate back to your workspace and select the '+ New Item' button at the top left of your workspace.

New_item_button_in_Fabric_workspaceNew_item_button_in_Fabric_workspace

Select the 'Data pipeline' item under the Get data group towards the top of the New item list.

Data_pipeline_item_in_Fabric_New_item_paneData_pipeline_item_in_Fabric_New_item_pane

Name your data pipeline and select the 'Create' button.

Create_a_new_data_pipeline_item_with_an_option_to_name_your_item_and_either_CreaCreate_a_new_data_pipeline_item_with_an_option_to_name_your_item_and_either_Crea

When your data pipeline has been created, you will have an option to Start with a blank canvas. Select the 'Pipeline activity' button and navigate to the Orchestrate section of the dropdown towards the bottom of the activity list.

Select the 'Functions' button to create your functions activity.

Data_pipeline_canvas_upon_initial_creation._When_clicking_the_Pipeline_activityData_pipeline_canvas_upon_initial_creation._When_clicking_the_Pipeline_activity

You’ll now see a functions activity has been added to your data pipeline's canvas. Notice that when you toggle into the functions activity by selecting it, you can view the General tab and Settings tab.

Functions_activity_in_pipelines_canvas_with_a_General_tab_followed_by_a_SettingsFunctions_activity_in_pipelines_canvas_with_a_General_tab_followed_by_a_Settings

Step 6: Utilize User Data Functions inside of your function's activity

While toggling into your Functions activity by selecting it, navigate to the General tab. You'll find a required Name section that comes auto filled with a name. You can rename your function to better describe your functions. In this tutorial, we've decided to name our functions activity "UDF hello_world".

Renaming_the_functions_activity_through_the_General_settingsRenaming_the_functions_activity_through_the_General_settings

Navigate the Settings tab in your function's activity. You’ll find that you’ll be able to select the Type of function you’d like to use. In today’s demo, we'll keep the 'Fabric user data functions' type selected.

Next, select the dropdown for Connection to configure your connection to your User Data Function item.

Settings_panel_of_the_functions_activity_that_has_options_for_Type_Connection_WoSettings_panel_of_the_functions_activity_that_has_options_for_Type_Connection_Wo

When selecting the Connection dropdown, you will be prompted to the Get data experience. You will start by choosing a data source to get started. Start by selecting 'User Data Functions' as your source under the New sources section towards the top of the panel.

First_part_of_the_Get_data_experience_where_you_can_Choose_a_data_source_to_getFirst_part_of_the_Get_data_experience_where_you_can_Choose_a_data_source_to_get

Next in the Get data experience, you'll need to connect to your data source. To do so, opt to create a new connection in the Connection dropdown.

Then, name your Connection name anything you’d like to. In this tutorial, we've named the connection 'My UDF Connection'.

Then, sign into your Fabric account. You can ignore the other sections of the Connection credentials for this tutorial.

Once you complete these steps, the 'Connect' button will be enabled. Select the 'Connect' button at the bottom right of the Get data experience to proceed.

Second_part_of_the_Get_data_experience_where_you_can_Connect_to_a_data_sourceSecond_part_of_the_Get_data_experience_where_you_can_Connect_to_a_data_source

You have now configured your connection as you'll see that the Connection section of Settings is now filled out with your connection credentials.

From the Workspace section in Settings, select the Fabric workspace you created your User Data Functions item in by toggling into the Workspace dropdown.

Find the name of your User Data Functions item within the dropdown of the User data functions section of Settings. In today’s tutorial, we named our User Data Functions item 'My User Data Function'.

Navigate to the function you’d like to use in the Function dropdown of Settings. In today's tutorial, we used a sample function named "hello_fabric".

Configuring_functions_activity_settings_by_filling_out_Type_Connection_WorkspaceConfiguring_functions_activity_settings_by_filling_out_Type_Connection_Workspace

Since we are using the sample “hello_fabric” function, it requires a parameter of name that comes in the form of a string. So, input your name in the Value section of Parameters.

Input_example_name_Connie_in_Value_section_of_Parameters_within_your_functionInput_example_name_Connie_in_Value_section_of_Parameters_within_your_function

Step 7: Save and run your Data pipeline to confirm your User Data Function in the function's activity work

At the top left of the pipeline builder navigation bar, select the 'Save' button.

Purple_save_button_from_pipelines_editor_navigation_barPurple_save_button_from_pipelines_editor_navigation_bar

Once your data pipeline is saved, select the 'Run' button just a few items to the right of the Save button.

Run_button_from_pipelines_editor_navigation_barRun_button_from_pipelines_editor_navigation_bar

When your date pipeline successfully runs, you’ll be able to check the Input and Output of your pipeline to make sure that it aligns with your User Data Function. You can do this by selecting the input icon or output icon of your function's activity.

Pipelines_run_outputs_sorted_by_activities_in_your_pipelinePipelines_run_outputs_sorted_by_activities_in_your_pipeline

Let's select the input icon for our function's activity "UDF hello_world" that we created in this tutorial. The expected input in this tutorial is the value of the name you chose to type into the Parameters section your functions activity Settings.

When you are done checking your input for the function's activity, you can select the 'X' at the top right of the input pop-out to exit out of the view.

Input_of_functions_activity_with_parameter_of_name_and_name_inputInput_of_functions_activity_with_parameter_of_name_and_name_input

Now, let's select the output icon for your function's activity. The expected output in this tutorial is the welcome message: 'Welcome to Fabric Functions, {the name value you input}, at {current date and time}!'.

When you are done checking your output for the function's activity, you can select the 'X' at the top right of the input pop-out to exit out of the view.

Output_of_functions_activity_that_displayed_a_welcome_message_with_the_name_inpuOutput_of_functions_activity_that_displayed_a_welcome_message_with_the_name_inpu

Congratulations! You’ve now learned how to use User Data Functions inside of your data pipeline!

Next steps

Check out our documentation to learn more about the Functions activity in Data pipelines today. Submit your feedback on Fabric Ideas and join the conversation on the Fabric Community