3

I have a durable azure function (2.0) that calls back on itself for an eternal orchestration, based on this article. Code below. This works fine and runs well for approx 20 minutes (say around 50 iterations). However, after this time it goes to sleep and stops working. If I navigate to the Azure portal and just click on the functions app and click the functions list (i.e. I just click around but don't change any settings or stop/start anything) it suddenly "wakes up" and continues on no problem. There are no errors or issues in the logs, just a indication of the inactive period and then the logs resuming. Am I missing a setting somewhere?

public static async Task Run([OrchestrationTrigger] DurableOrchestrationContextBase ctx, ILogger log)
{
    try
    {
        var config = ctx.GetInput<Config>();
        config = await ctx.CallActivityAsync<Config>("GetConfig", null);
        await ctx.CallActivityAsync("ProcessDetails", config);

        var nextCheckpoint = ctx.CurrentUtcDateTime.AddSeconds(config.PollingIntervalInSeconds);

        await ctx.CreateTimer(nextCheckpoint, CancellationToken.None);             
        ctx.ContinueAsNew(config);   
    }
    catch (Exception ex)
    {
        log.LogError($"[Error!][Failed with: {ex.ToString()}]");
        throw;
    }
}

After hitting the refresh button as described by @davidebbo the issue still persists, see log below.

enter image description here

Further update, even though the issue on GitHub appears resolved, I still needed to do the double config setting as indicated below in order to get my function reliable.

{
  "version": "2.0",
  "extensions": {

    "durableTask": {
      "HubName": "myHub",
      "maxConcurrentActivityFunctions": 10,
      "maxConcurrentOrchestratorFunctions": 1
    }
  },
  "durableTask": {
    "HubName": "myHub",
    "maxConcurrentActivityFunctions": 10,
    "maxConcurrentOrchestratorFunctions": 1
  },
  "functionTimeout": "00:10:00"
} 

Now still having issues after much code optimisation, even though metrics look rock solid.

enter image description here

4

2 回答 2

2

当您为 Func 使用 Consumption Plan 时,可能会发生这种情况。这意味着,经过一段时间的感染后,azure 将暂停您的 Func,并且当系统中出现新事件或请求时,它将重新激活您的功能。要解决此问题,您可以执行以下操作:

  • 使用应用服务计划
  • 使用高级计划
  • 创建一些应用程序来预热您的功能。

您可以在本文中阅读更多详细信息

于 2020-04-02T14:49:15.520 回答
1

您很可能遇到了这个问题

该问题现已修复,但如果您受到影响,您需要在修复完成后明确同步触发器一次。为此,请转到门户中的函数应用程序,然后单击树中函数应用程序名称旁边的小刷新图标。你只需要这样做一次。

然后您可以离开门户,它应该会继续愉快地运行。

于 2018-10-08T00:20:34.283 回答