I am getting issue while making post request to durable functions (extension of Azure Functions) from ADF and from Postman

Viewed 1351

I am able to call azure functions from ADF and postman but when I call durable functions from ADF or postman it gives me error:

Operation on target Azure Function1 failed: Call to provided Azure function '' failed with status-'NotFound' and message - 'Invoking Azure function failed with HttpStatusCode - NotFound.'.

I have tried everything but dont know why this is happening. I have created durable function through portal in functionApp as follow:

DurableFunctionsHttpStart1:

#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"
#r "Newtonsoft.Json"

using System.Net;

public static async Task<HttpResponseMessage> Run(
    HttpRequestMessage req,
    DurableOrchestrationClient starter,
    ILogger log)
{
    // Function input comes from the request content.
    dynamic eventData = await req.Content.ReadAsAsync<object>();

    // Pass the function name as part of the route 
    string instanceId = await starter.StartNewAsync("DurableFunctionsOrchestrator1", null);

    log.LogInformation($"Started orchestration with ID = '{instanceId}'.");

    return starter.CreateCheckStatusResponse(req, instanceId);
}

DurableFunctionsOrchestrator1:

/*
 * This function is not intended to be invoked directly. Instead it will be
 * triggered by an HTTP starter function.
 * 
 * Before running this sample, please:
 * - create a Durable activity function (default name is "Hello")
 * - create a Durable HTTP starter function
 */

#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"

public static async Task<List<string>> Run(DurableOrchestrationContext context)
{
    var outputs = new List<string>();

    // Replace "Hello" with the name of your Durable Activity Function.
    outputs.Add(await context.CallActivityAsync<string>("Hello1", "Tokyo"));
    outputs.Add(await context.CallActivityAsync<string>("Hello1", "Seattle"));
    outputs.Add(await context.CallActivityAsync<string>("Hello1", "London"));

    // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
    return outputs;
}

Hello1:

/*
 * This function is not intended to be invoked directly. Instead it will be
 * triggered by an orchestrator function.
 * 
 * Before running this sample, please:
 * - create a Durable orchestration function
 * - create a Durable HTTP starter function
 */

#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"

using System;
using System.Threading;

public static string Run(string name)
{
    Thread.Sleep(260000);
    return $"Hello {name}!";
}

From ADF side I am calling DurableFunctionsHttpStart1 function, which will call orchestrator function and activity will be called. Please guide

1 Answers

Update: Reproduce your error on ADF, this is what you are facing now:

enter image description here

If your function in ADF is like this, you will get the above error. enter image description here (Also the method need to be post)

This is the configuration of the azure function in ADF should be:

enter image description here

Then it works fine on my ADF.

Original Answer:

These code work fine on my side:

DurableFunctionsHttpStart1

#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"
#r "Newtonsoft.Json"

using System.Net;

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>();

    // Pass the function name as part of the route 
    string instanceId = await starter.StartNewAsync("DurableFunctionsOrchestrator1", eventData);

    log.LogInformation($"Started orchestration with ID = '{instanceId}'.");

    return starter.CreateCheckStatusResponse(req, instanceId);
}

DurableFunctionsOrchestrator1

/*
 * This function is not intended to be invoked directly. Instead it will be
 * triggered by an HTTP starter function.
 * 
 * Before running this sample, please:
 * - create a Durable activity function (default name is "Hello")
 * - create a Durable HTTP starter function
 */

#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"

public static async Task<List<string>> Run(DurableOrchestrationContext context)
{
    var outputs = new List<string>();

    // Replace "Hello" with the name of your Durable Activity Function.
    outputs.Add(await context.CallActivityAsync<string>("Hello1", "Tokyo"));
    outputs.Add(await context.CallActivityAsync<string>("Hello1", "Seattle"));
    outputs.Add(await context.CallActivityAsync<string>("Hello1", "London"));

    // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
    return outputs;
}

Hello1

/*
 * This function is not intended to be invoked directly. Instead it will be
 * triggered by an orchestrator function.
 * 
 * Before running this sample, please:
 * - create a Durable orchestration function
 * - create a Durable HTTP starter function
 */

#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"
using System;
using System.Threading;
public static string Run(string name)
{
    Thread.Sleep(260000);
    return $"Hello {name}!";
}

And all the function triggered well, at last:

enter image description here

Related