AZURE DATA FACTORY STORED PROCEDURE WITH POSTGRESQL SERVER

Sai Varma Eswararaju 0 Reputation points
2024-05-21T05:42:27.17+00:00

Dear Microsoft Support,

I have created a stored procedure in a PostgreSQL server and established a linked service for that server in Azure Data Factory (ADF). My goal is to execute this stored procedure within a pipeline in ADF. However, when I attempt to connect to the stored procedure, my linked service does not appear as an option.

Upon seeking guidance from Copilot, I learned that ADF does not currently support stored procedures in PostgreSQL. Could you please provide guidance on how I can execute my PostgreSQL stored procedure within an ADF pipeline?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
Azure Database for PostgreSQL
{count} votes

2 answers

Sort by: Most helpful
  1. Smaran Thoomu 24,110 Reputation points Microsoft External Staff Moderator
    2024-05-21T06:52:48.8766667+00:00

    Hi @Sai Varma Eswararaju

    Thank you for reaching out to the community forum with your query.

    I understand that you are trying to execute a stored procedure in a PostgreSQL server within an Azure Data Factory (ADF) pipeline, but your linked service does not appear as an option. Unfortunately, ADF does not currently support stored procedures in PostgreSQL.

    However, there are a few workarounds that you can try to execute your PostgreSQL stored procedure within an ADF pipeline:

    1. Use an Azure Function to execute the stored procedure: You can create an Azure Function that connects to your PostgreSQL server and executes the stored procedure. Then, you can call this Azure Function from your ADF pipeline using the Azure Function activity.
    2. Use a custom activity: You can create a custom activity in ADF that connects to your PostgreSQL server and executes the stored procedure. You can use a .NET custom activity or a Python custom activity to achieve this.
    3. Use a third-party connector: You can use a third-party connector like the CData PostgreSQL Connector for ADF to connect to your PostgreSQL server and execute the stored procedure.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

  2. Yugandhar Mayekar 0 Reputation points
    2024-11-28T07:42:58.0933333+00:00

    Hi,
    It's correct that ADF does not currently support the direct execution of stored procedures in PostgreSQL. However, we can execute PostgreSQL functions using the Lookup Activity in ADF. Here's how:

    Leverage PostgreSQL Functions: Create a PostgreSQL function that encapsulates the required logic. Unlike stored procedures, functions can be invoked directly using a query.

    1. Executing the Function: In the Lookup Activity, write a query in the format:
      1. SELECT your_function(arguments);
        This syntax ensures the function is executed, and any returned value is captured by the Lookup Activity. This syntax ensures the function is executed, and any returned value is captured by the Lookup Activity.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.