Я получаю сообщение об ошибке при отправке запроса на постоянные функции (расширение Azure функций) из АПД и Почтальона - PullRequest
1 голос
/ 27 февраля 2020

Я могу вызвать azure функции из АПД и почтальона, но когда я вызываю долговременные функции из АПД или почтальона, это выдает мне ошибку:

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

Я перепробовал все, но не знаю, почему это происходит. Я создал долговременную функцию через портал в functionApp следующим образом:

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}!";
}

Со стороны ADF я вызываю функцию DurableFunctionsHttpStart1, которая вызовет функцию оркестратора и будет вызвана активность. Пожалуйста, руководство

1 Ответ

1 голос
/ 27 февраля 2020

Обновление: Воспроизведите ошибку на АПД, с этим вы столкнулись сейчас:

enter image description here

Если ваша функция в ADF так, вы получите вышеупомянутую ошибку. enter image description here (также метод должен быть опубликован)

Это конфигурация функции azure в АПД должна быть:

enter image description here

Тогда он отлично работает на моем АПД.

Оригинальный ответ:

Этот код отлично работает на моей стороне:

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}!";
}

И все функции сработали, наконец-то:

enter image description here

...