0
votes

I need to pass header information in Azure Function activity in Data Factory. As can be seen in the picture, the header is marked in red.

I need to change the following code to receive the header. I also need to capture the value of the header.

public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "{name}" )] HttpRequestMessage req, string name, TraceWriter log, [Blob("pk-api-test/{name}", FileAccess.Read)] Stream myBlob)

enter image description here

2
Do you mean you don't want to use Route anymore, instead, you want to pass header info to http trigger and capture the info to retrieve blob?Jerry Liu
Yes @JerryLiu that's what I wanted to do.binit joshi
@JerryLiu This threw me an error. So, I solved it by using 'Route = TestFunction/ {name}' in the code and in the Azure function settings in Data Factory, I used the Function Name = TestFunction/albanybinit joshi

2 Answers

1
votes

I solved it by using 'Route = TestFunction/{name}' in the code and in the Azure function settings in Data Factory, I used the Function Name = TestFunction/albany

0
votes

Have a try at code below. Use headers to access headers info in http request.

   public static async Task Run(
         [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)]HttpRequestMessage req,
         [Blob("pk-api-test/{headers.name}", FileAccess.Read)]Stream myBlob, 
         IDictionary<string, string> headers,
         TraceWriter log)
   {
       string name = headers["name"];
       //...
   }