逻辑应用和Azure功能耐用功能不适合

时间:2018-02-13 21:10:54

标签: azure-functions azure-logic-apps

我遇到了Azure Logic App和Azure Functions Durable Functions的一个奇怪问题,这让我很烦恼。

这里是上下文:我的工作流调用Azure函数,因为我想将数据插入数据库。因为这个过程可能很长,所以我使用Durable Functions(感谢NuGet软件包Microsoft.Azure.WebJobs.Extensions.DurableTask版本1.1.0-beta2)。 由于来自SFTP服务器的XML文件,插入了数据。在工作流程中,我们将其创建为存储帐户容器中的Blob。之后,它调用Azure Functions。

我的Azure功能代码中有3种方法: - "运行" (HttpTrigger) - " RunOrchestrator" (OrchestrationTrigger) - " DoWork" (ActivityTrigger)

以下是我的代码示例:

HttpStart.cs

[FunctionName("InsertDataInDatabase_Start")]
public static async Task<HttpResponseMessage> Run(
    [HttpTrigger(AuthorizationLevel.Function, "post")]HttpRequestMessage req,
    [OrchestrationClient]DurableOrchestrationClient starter,
    TraceWriter log)
{
    try
    {
        log.Info($"C# Http trigger InsertDataInDatabase_Start processed.");

        // Function input comes from the request content.
        var content = await req.Content.ReadAsStringAsync();
        ProcessRequest requestData = new ProcessRequest
        {
            Data = content
        };

        log.Info($"Calling orchestrator...");
        string instanceId = await starter.StartNewAsync("InsertDataInDatabase_Orchestrator", requestData);
        log.Info($"End call orchestrator");

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

        var response = starter.CreateCheckStatusResponse(req, instanceId);

        // I specify a response interval so the Logic App doesn't check the status
        // until after 10 seconds has passed. If work will be longer you can change this 
        // value as needed.
        response.Headers.RetryAfter = new RetryConditionHeaderValue(TimeSpan.FromMinutes(3));
        return response;
    }
    catch (Exception ex)
    {
        log.Error($"Error : {ex.Message}");
        return req.CreateResponse(HttpStatusCode.InternalServerError, ex.Message);
    }
}

Orchestrator.cs:

    [FunctionName("InsertDataInDatabase_Orchestrator")]
    public static async Task<List<string>> RunOrchestrator(
        [OrchestrationTrigger] DurableOrchestrationContext context, TraceWriter log)
    {
        log.Info("Orchestrator running...");
        try
        {
            var outputs = new List<string>
            {
                await context.CallActivityAsync<string>("InsertDataInDatabase_DoWork", context.GetInput<ProcessRequest>())
            };
            return outputs;
        }
        catch (Exception ex)
        {
            log.Error($"ERROR: {ex.Message}");
            throw ex;
        }
    }

DoWork.cs:

    [FunctionName("InsertDataInDatabase_DoWork")]
    public static async Task<string> DoWork(
        [ActivityTrigger] ProcessRequest requestData,
        TraceWriter log)
    {
        log.Info($"C# Http trigger function InsertDataInDatabase_DoWork Processed.");

        // Processing requestData

        return "Operation done.";
    }

ProcessRequest对象是一个包含单个字段的简单类(处理XML文件内容的Data,包含有关要插入数据库的对象的数据):

public class ProcessRequest
{
    public string Data { get; set; }
}

我面临的问题如下:当我查看第一个Azure功能的监视器时,它确实被称为:)但是当我查看Orchestrator监控时,会出现这样的问题。没有活动迹象:S 我不知道什么是错的,我怀疑是NuGet包,因为它处于测试阶段,不幸的是目前还没有更新。

有什么想法吗?谢谢

0 个答案:

没有答案