1
votes

I'm upgrading an Azure Durable Function project from .NET Core 2.1 to 2.2. I updated all NuGet packages to the latest releases that are compatible with .NET Core 2.2 (to my knowledge). The Durable Client function (StartOrchestration) is configured with a timer trigger (shown below) which is working as expected.

What isn't working is that the Orchestration Trigger function (SearchOrchestration) is never called and I have no idea why. Did I update to an invalid NuGet package(s)? Is there something obvious wrong that I'm just not seeing?

For reference, I've been looking at the Bindings for Durable Functions document and it would appear like my code should work... but it doesn't.

The durable function orchestration:

    public static class SearchIndexDurableFunctions
    {
        [FunctionName(nameof(StartOrchestration))]
        public static async Task StartOrchestration(
            [TimerTrigger("%CronExpression%")]TimerInfo myTimer,
            [DurableClient(TaskHub = "%TaskHub:Name%")]IDurableOrchestrationClient starter,
            ILogger logger)
        {
            var nextRunTime = myTimer.Schedule.GetNextOccurrence(DateTime.Now);
            logger.LogInformation($">> Next run time will be: {nextRunTime.ToLocalTime()}");

            var instanceId = Guid.NewGuid().ToString();

            var result = await starter.StartNewAsync(nameof(SearchOrchestration), instanceId);
        }

        [FunctionName(nameof(SearchOrchestration))]
        public static async Task SearchOrchestration(
            [OrchestrationTrigger]IDurableOrchestrationContext context,
            ILogger logger)
        {
            try
            {
                await context.CallActivityAsync(nameof(SearchPartIndexFunctionActivity), null);

                await context.CallActivityAsync(nameof(SearchProductIndexFunctionActivity), null);
            }
            catch (FunctionFailedException ex)
            {
                logger.LogError(ex, $"Search index orchestration failed.");
            }
        }

        [FunctionName(nameof(SearchPartIndexFunctionActivity))]
        public static async Task SearchPartIndexFunctionActivity(
            [ActivityTrigger]string input,
            ExecutionContext context,
            ILogger logger)
        {
            logger.LogInformation("Started SearchPartIndexFunctionActivity...");

            var busLogic = new SearchPartIndexFunctionBase(context, logger);
            await busLogic.UpdateIndexAndData();

            logger.LogInformation("Finished SearchPartIndexFunctionActivity successfully.");
        }

        [FunctionName(nameof(SearchProductIndexFunctionActivity))]
        public static async Task SearchProductIndexFunctionActivity(
            [ActivityTrigger]string input,
            ExecutionContext context,
            ILogger logger)
        {
            logger.LogInformation("Started SearchProductIndexFunctionActivity...");

            var busLogic = new SearchProductIndexFunctionBase(context, logger);
            await busLogic.UpdateIndexAndData();

            logger.LogInformation("Finished SearchProductIndexFunctionActivity successfully.");
        }
    }

The .csproj file showing NuGet package versions:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
    <AssemblyName>[Company Name].Interface.Search</AssemblyName>
    <RootNamespace>[Company Name].Interface.Search</RootNamespace>
    <LangVersion>7.2</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="AutoMapper" Version="9.0.0" />
    <PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.9.2" />
    <PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.29.0" />
    <PackageReference Include="Microsoft.Azure.Management.TrafficManager.Fluent" Version="1.29.0" />
    <PackageReference Include="Microsoft.Azure.Search" Version="10.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.5" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.2" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Host.Storage" Version="3.0.14" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.1.3" />
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.4" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.2" />
    <PackageReference Include="[Company Name].Core.Repositories" Version="1.0.20191218.1" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>
2
Hi, show your .csproj file. Don;t use the picture.Cindy Pau
@BowmanZhu Thank you for the suggestion. I've updated my question.PoorInRichfield

2 Answers

1
votes

Seems problem comes from your [DurableClient(TaskHub = "%TaskHub:Name%")]

Other code is no problem.

Function works on my side like this:

    public static void TimerStart(
        [TimerTrigger("*/1 * * * * *")]TimerInfo myTimer,
        [DurableClient]IDurableOrchestrationClient starter,
        ILogger log)
    {
        // Function input comes from the request content.

        log.LogInformation($"==================================Started orchestration with ID");

    }
0
votes

For historical purposes

I deployed in production and everything was working perfectly. The problem came when I created a DEV slot.

Sometimes the production function "said" that the task was successfully executed. However, nothing had been done. Then the function would restart and everything would work again. But the problem always returned, for me the orchestrator was not running when calling StartNew

In the end, I found that, as the DEV and PROD environments were sharing the same Table Storage, the DEV environment was processing the production request when it was very busy. To resolve this, I had to deploy host.json with different hub names for each slot