Forum Discussion

Jerome22's avatar
Jerome22
Icon for Resolver I rankResolver I
1 year ago
Solved

user data functions + deployment pipeline, no variables ?

Hi,

 

how it's possible to manage the connections setup in an user data function in a deployment pipeline?

 

I have a UDF in a dev workspace which connects to a specific database, when I deploy my function in my production workspace, I want my function to be connected to another database not my development one.

how to do it?

 

I also need to use variables for other parameters used in my function which has to be changed between my dev and prod usage of my function.

 

maybe I can access variables setup in a workspace from within the UDF?

 

thanks.

5 Replies

  • david_avgarcia's avatar
    david_avgarcia
    Frequent Visitor
    @udf.connection(argName="testsqlDB", alias="testsqldb") @udf.connection(argName="prodsqlDB", alias="prodsqldb")  @udf.connection(argName="envConfig", alias="environmentConf")  @udf.function()  def FO_Subscribe_Unsubscribe(testsqlDB: fn.FabricSqlConnection, prodsqlDB: fn.FabricSqlConnection, envConfig: fn.FabricVariablesClient, IsUserSubscribed: int, UserEmail: str, FundingOpportunityID: str, FundingOpportunity: str) -> str:      # Step 1: call stored procedure that inserts or delete rows from the subscription table      try:                 connection = get_sql_connection(envConfig,testsqlDB,prodsqlDB)                cursor = connection.cursor()

    Since connection aliases currently appear to be static and deployment pipeline does not autobind connections, I implemented that workaround. Has anyone found a cleaner CI/CD approach for UDF connection management?

  • v-lgarikapat's avatar
    v-lgarikapat
    Icon for Community Support rankCommunity Support

    Hi Jerome22  

    Thanks for reaching out to the Microsoft fabric community forum.

    suparnababu8 

    Thanks for your prompt response

    Jerome22 ,

    I wanted to follow up and confirm whether you’ve had the opportunity to review the information  provided By suparnababu8  If you have any questions or need further clarification, please don’t hesitate to reach out.

     

    Best Regards,

    Lakshmi 

    • v-lgarikapat's avatar
      v-lgarikapat
      Icon for Community Support rankCommunity Support

      Hi Jerome22 ,

      I just wanted to check if your issue has been resolved. If you still have any questions or need help, feel free to reach out I’m happy to assist.

      Thank you for being an active part of the community. Looking forward to hearing from you!

      Best regards,
      Lakshmi

      • v-lgarikapat's avatar
        v-lgarikapat
        Icon for Community Support rankCommunity Support

        Hi Jerome22 ,

         

        I just wanted to check if your issue has been resolved. If you still have any questions or need help, feel free to reach out I’m happy to assist.

        Thank you for being an active part of the community. Looking forward to hearing from you!

        Best regards,
        Lakshmi

  • Hi Jerome22 

     

    You can use Varaiable Libraires in data pipelines(preview mode) Read more about variable libraries here Learn how to use Variable libraries - Microsoft Fabric | Microsoft Learn 

     

    But, while coming to UDF, as of now UDF's not supported to use direct access to Variable libraries inside UDF. As a work around you can use notebook that reads the values from variable library and it passes the values to the UDF as parameters. Then you can use the parameters to setup your conenctions dynamically. Just give a try.

     

    Pls read this blog User data functions source control and deployment - Microsoft Fabric | Microsoft Learn it may helps you

     

    Please let me know if it works.

     

     

    Thank you!

     

    Did I answer your question? Mark my post as a solution!

    Proud to be a Super User!