binit joshi
binit joshi

Reputation: 137

How to pass a route to Azure function (C#) http trigger in Data Factory pipeline?

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

Upvotes: 0

Views: 958

Answers (2)

binit joshi
binit joshi

Reputation: 137

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

Upvotes: 1

Jerry Liu
Jerry Liu

Reputation: 17800

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"];
       //...
   }

Upvotes: 0

Related Questions