Azure functions Microsoft.Azure.WebJobs.Host出现默认持久函数错误:无法绑定参数';起动器';

Azure functions Microsoft.Azure.WebJobs.Host出现默认持久函数错误:无法绑定参数';起动器';,azure-functions,Azure Functions,我刚刚开始使用Azure功能,特别是持久功能 我在工作 我添加了一个新的azure持久功能,默认代码如下所示 我看到我的库是持久函数版本2,所以我必须对类名做一些更改,以便解决它(链接位于上面讨论更改的链接中): [FunctionName(“TestFunction”)] 公共静态异步任务RunOrchestrator( [OrchestrationTrigger]IDurableOrchestrationContext(上下文) { 变量输出=新列表(); //将“hello”替换为持久活动

我刚刚开始使用Azure功能,特别是持久功能

我在工作

我添加了一个新的azure持久功能,默认代码如下所示

我看到我的库是持久函数版本2,所以我必须对类名做一些更改,以便解决它(链接位于上面讨论更改的链接中):

[FunctionName(“TestFunction”)]
公共静态异步任务RunOrchestrator(
[OrchestrationTrigger]IDurableOrchestrationContext(上下文)
{
变量输出=新列表();
//将“hello”替换为持久活动函数的名称。
Add(wait context.CallActivityAsync(“TestFunction_Hello”,“Tokyo”);
Add(wait context.CallActivityAsync(“TestFunction_Hello”,“西雅图”);
Add(wait context.CallActivityAsync(“TestFunction_Hello”,“London”));
//返回[“你好东京!”、“你好西雅图!”、“你好伦敦!”]
返回输出;
}
[FunctionName(“TestFunction_Hello”)]
公共静态字符串SayHello([ActivityTrigger]字符串名称,ILogger日志)
{
log.LogInformation($“向{name}打招呼”);
return$“Hello{name}!”;
}
[FunctionName(“TestFunction\u HttpStart”)]
公共静态异步任务HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous,“获取”、“发布”)]HttpRequestMessage请求,
[OrchestrationClient]IDurableOrchestrationClient启动程序,ILogger日志)
{
//函数输入来自请求内容。
字符串instanceId=await starter.StartNewAsync(“TestFunction”,null);
LogInformation($“启动了ID为“{instanceId}”的业务流程”;
返回starter.CreateCheckStatusResponse(请求,实例ID);
}
当我在本地运行此程序时,它会启动存储模拟器,但随后会出现两个错误:

Microsoft.Azure.WebJobs.Host:索引方法“TestFunction\u HttpStart”时出错。Microsoft.Azure.WebJobs.Host:无法将参数“starter”绑定到类型IDurableOrchestrationClient。确保绑定支持该参数类型。如果您正在使用绑定扩展(例如Azure存储、ServiceBus、计时器等),请确保已在启动代码中调用扩展的注册方法(例如builder.AddAzureStorage()、builder.AddServiceBus()、builder.AddTimers()等)

Microsoft.Azure.WebJobs.Host:索引方法“TestFunction\u HttpStart”时出错。Microsoft.Azure.WebJobs.Host:无法将参数“starter”绑定到类型IDurableOrchestrationClient。确保绑定支持该参数类型。如果您正在使用绑定扩展(例如Azure存储、ServiceBus、计时器等),请确保已在启动代码中调用扩展的注册方法(例如builder.AddAzureStorage()、builder.AddServiceBus()、builder.AddTimers()等)


为什么默认测试代码中会出现这些错误?我如何修复它?

您没有将
OrchestrationClient
属性更改为
DurableClient
,如1.x中的--
OrchestrationClientAttribute
中提到的
DurableClientAttribute

    [FunctionName("TestFunction")]
    public static async Task<List<string>> RunOrchestrator(
        [OrchestrationTrigger] IDurableOrchestrationContext context)
    {
        var outputs = new List<string>();

        // Replace "hello" with the name of your Durable Activity Function.
        outputs.Add(await context.CallActivityAsync<string>("TestFunction_Hello", "Tokyo"));
        outputs.Add(await context.CallActivityAsync<string>("TestFunction_Hello", "Seattle"));
        outputs.Add(await context.CallActivityAsync<string>("TestFunction_Hello", "London"));

        // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
        return outputs;
    }

    [FunctionName("TestFunction_Hello")]
    public static string SayHello([ActivityTrigger] string name, ILogger log)
    {
        log.LogInformation($"Saying hello to {name}.");
        return $"Hello {name}!";
    }

    [FunctionName("TestFunction_HttpStart")]
    public static async Task<HttpResponseMessage> HttpStart(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
        [OrchestrationClient]IDurableOrchestrationClient starter, ILogger log)
    {
        // Function input comes from the request content.
        string instanceId = await starter.StartNewAsync("TestFunction", null);

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

        return starter.CreateCheckStatusResponse(req, instanceId);
    }