How to pass string output of set varibale activity to azure function activity for POST request in adf

Amar Agnihotri 926 Reputation points
2022-07-07T07:06:46.59+00:00

Hi,
I have this pipeline
218418-image.png

This is my azure function which is converting the string to valid json string
218457-image.png

This function will take string output from "Change Array To string " activity and will convert this string to a valid json format. After that i will copy that string to datalalke.

I am unable to get that how can i pass the output to azure function activity for POST request

"Change Array To String" activity is holding an output in Data2 variable as shown
218483-image.png

Now i want to pass this value of Data2 varibale to name variable in azure function . I tried this in azure function activity
218419-image.png

But My function is not able to run showing the below error -

218504-image.png

Can anyone suggest something to resolve this ?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,624 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Nasreen Akter 10,811 Reputation points Volunteer Moderator
    2022-07-07T13:07:59.3+00:00

    Hi @Amar Agnihotri ,

    Thank you for the ask. Function Body seems incorrect. It should be a valid JSON. Would you please try something like:

    {
    "name": "@{variables('Data2')}"
    }

    Hope this helps. Thank you!

    1 person found this answer helpful.

  2. Amar Agnihotri 926 Reputation points
    2022-07-09T08:22:47.04+00:00

    Hi @Nasreen Akter
    Thanks for the reply. Let me show you where am i stuck at right now -

    I create my azure function in Visual studio and published it to azure. The function is taking string and converting it to the json format .
    This is the input string to the function -
    219111-image.png
    I put this input to check azure function in portal
    219121-image.png

    and this is the output of azure function which is a valid json format

    219024-image.png

    I checked this function in Postman too and it is working fine. You can see i checked the output in jsonlint.com for the valid format and we are getting what we want
    219122-azure-function.gif

    In both the azure portal and postman my function is working fine but when i checked this in adf pipeline in azure function activity it is not working it is returning the same input string . I believe it is not getting the value for the name . You can see that the function is being called -
    219102-image.png

    but it is not returning the valid output
    219113-image.png

    I am not able to understand why it is not working fine in function activity in adf. You can see that i passed the hard coded value in the body in the same way as i did in azure portal and postman -
    219018-image.png

    Am i doing any mistake in the body section to pass the value for the name variable of function ?

    This is my azure function code -

    219065-image.png

    Can you please tell me what i am doing wrong while making a call in adf.

    0 comments No comments

  3. Amar Agnihotri 926 Reputation points
    2022-08-03T07:45:17.717+00:00
    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.