Issue while passing content as a body to azure function in adf.

Amar Agnihotri 891 Reputation points

I have created an azure function which is getting an input string and converting it to the valid Json format. The function is working fine in azure portal and in postman. This is the format of input string that it is taking

and i
this is the format of output string in which it is converting -


This is working fine in azure portal where input string is being passed as -

And creating a valid output

Now in adf the input to the function is coming from the variable from the previous activity -


This is the data the variable is holding
( Name of variable is Data2 and this is of string type )-

Now i passed this data2 variable value as input to azure function activity as

When pipeline runs it throws an error -

I found in the output that the input is being passed to azure function in some disturbed format -

but for function to work . The input to the function should be like -
So i believe that there is something missing in passing the content as body to azure function . Please suggest something to get this resolved.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,013 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,120 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Amar Agnihotri 891 Reputation points


    Hi, The issue has been resolved . Actually, in adf azure function activity the content inside the body is passed as a text to the azure function . Adf doesn't pass the content as a json and since i had defined in the azure function definition to read body content as a json object so that's why it was not picking up the input but when i was trying the same input in the azure function app then it was working fine. I changed the code in function definition to read the content body as a string rather than as a json object then it started working fine. Also, i want to tell you that i tried using @json (variables('data2')) also but that was also not working

    Thanks for your support

    2 people found this answer helpful.

  2. MartinJaffer-MSFT 25,991 Reputation points

    Hello @Amar Agnihotri ,
    Thanks for the question and using MS Q&A platform.

    As I understand you are trying to use Azure Functions to do some transformation from Data Factory. You are not getting the body you expected.

    You showed your body was


    specifying "body" within the body is excessive. The contenst of the entire textbox are the body. you only need to do:



    Please do let me if you have any queries.


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

  3. Amar Agnihotri 891 Reputation points


    here is the full code of function in txt file