Reputation: 4260
Have a queue-triggered function defined as the following example:
public async Task OrchestratorAsync(
[QueueTrigger("my-queue", Connection = "")]string payload,
[OrchestrationClient] DurableOrchestrationClient orchestrationClient)
{
//Do something
}
The csproj file looks like the following details and it compiles successfully:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
</ItemGroup>
</project>
When I upgrade Microsoft.Azure.WebJobs.Extensions.DurableTask
to version 2.0.0 the compiler throws error on not being able to find OrchestrationClient and DurableOrchestrationClient. So we're stuck with version 1.8.2! What's the solution for this issue?
Note: This issue is quite reproducible by VS 2019. Have it scaffold a Function project, the create another function as a durable orchestrator, tweak the csproj file and bump up the DurableTask nuget package version to 2.0.0 from the default 1.8.2.
Upvotes: 1
Views: 4778
Reputation: 14108
I have reproduce your error, and I solved this problem.
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace _11111fc
{
public static class Function1
{
[FunctionName("Function1")]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context,
[DurableClient] IDurableOrchestrationClient orchestrationClient)
{
var outputs = new List<string>();
// Replace "hello" with the name of your Durable Activity Function.
outputs.Add(await context.CallActivityAsync<string>("Function1_Hello", "Tokyo"));
outputs.Add(await context.CallActivityAsync<string>("Function1_Hello", "Seattle"));
outputs.Add(await context.CallActivityAsync<string>("Function1_Hello", "London"));
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return outputs;
}
[FunctionName("Function1_Hello")]
public static string SayHello([ActivityTrigger] string name, ILogger log)
{
log.LogInformation($"Saying hello to {name}.");
return $"Hello {name}!";
}
[FunctionName("Function1_HttpStart")]
public static async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
[DurableClient]IDurableOrchestrationClient starter,
ILogger log)
{
// Function input comes from the request content.
string instanceId = await starter.StartNewAsync("Function1", null);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
return starter.CreateCheckStatusResponse(req, instanceId);
}
}
}
Solution:
Change [OrchestrationClient] to [DurableClient]. Have a look of this.
Please take care of the breaking changes in Durable Functions v2.0.0-beta2 Release
, the OrchestrationClient
has been renamed.
Things works fine on my side. Please have a try on your side.
Upvotes: 12