简体   繁体   中英

Azure Orchestration Function: How to get Http request header?

I have an HTTP trigger that calls an orchestration function:

    [FunctionName("HttpStart")]
    public static async Task<HttpResponseMessage> Run(
        [HttpTrigger(AuthorizationLevel.Function, methods: "post", Route = "orchestrators/{functionName}")] HttpRequestMessage req,
        [OrchestrationClient] DurableOrchestrationClientBase starter,
        string functionName,
        ILogger log)
    {
        // Function input comes from the request content.
        dynamic eventData = await req.Content.ReadAsAsync<object>();
        string instanceId = await starter.StartNewAsync(functionName, eventData);

The header of the orchestration function looks like this:

public static async Task Run([OrchestrationTrigger] DurableOrchestrationContextBase context, TraceWriter log)

Given that I don't have an HTTP context in the orchestration function, how can I forward a request header into the orchestration function from the HTTP trigger?

Took a look at this sample :

 #r "Microsoft.Azure.WebJobs.Extensions.DurableTask" #r "Microsoft.Extensions.Logging" #r "Newtonsoft.Json" using System.Net; using System.Net.Http.Headers; public static async Task<HttpResponseMessage> Run( HttpRequestMessage req, DurableOrchestrationClient starter, string functionName, ILogger log) { // Function input comes from the request content. dynamic eventData = await req.Content.ReadAsAsync<object>(); string instanceId = await starter.StartNewAsync(functionName, eventData); log.LogInformation($"Started orchestration with ID = '{instanceId}'."); return starter.CreateCheckStatusResponse(req, instanceId); } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM