从计时器触发的Azure函数调用另一个Azure函数

从计时器触发的Azure函数调用另一个Azure函数,azure,azure-functions,azure-functions-core-tools,timer-trigger,Azure,Azure Functions,Azure Functions Core Tools,Timer Trigger,我想从计时器触发的azure函数调用另一个(非计时器触发的)azure函数。 它可以编译,但在运行时我收到错误: System.ArgumentException: 'The function 'HelloWorld' doesn't exist, is disabled, or is not an orchestrator function. Additional info: No orchestrator functions are currently registered!' 我把它简化

我想从计时器触发的azure函数调用另一个(非计时器触发的)azure函数。 它可以编译,但在运行时我收到错误:

System.ArgumentException: 'The function 'HelloWorld' doesn't exist, is disabled, or is not an orchestrator function. Additional info: No orchestrator functions are currently registered!'
我把它简化为这个小代码段

    [FunctionName("HelloWorld")]
    public static string HelloWorld([ActivityTrigger] string name, ILogger log)
    {
        return $"Hello {name}!";
    }

    [FunctionName("DownloadLiveList")]
    public async void DownloadLiveList([DurableClient] IDurableOrchestrationClient client, [TimerTrigger("0 0 0 * * *", RunOnStartup = true)]TimerInfo myTimer, ILogger log)
    {
        await client.StartNewAsync<string>("HelloWorld", "Magdeburg");
    }
[FunctionName(“HelloWorld”)]
公共静态字符串HelloWorld([ActivityTrigger]字符串名称,ILogger日志)
{
return$“Hello{name}!”;
}
[FunctionName(“DownloadLiveList”)]
public async void DownloadLiveList([DurableClient]IDurableOrchestrationClient客户端,[TimerTrigger(“0 0***”,runnstartup=true)]TimerInfo myTimer,ILogger日志)
{
等待客户。StartNewAsync(“HelloWorld”、“Magdeburg”);
}

我从微软官方的例子中得到了这种azure函数级联的想法,我不知道为什么函数“HelloWorld”没有注册。上载到azure后,该函数与类中的所有其他函数一样在azure门户中可见。

您的时间触发器函数需要调用使用持久函数框架编写的启动函数。以下是一个示例:

[FunctionName("Function1")]
public async Task Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, ILogger log)
{
    log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

    var url = "http://localhost:7071/api/Durable_Starter";
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.AutomaticDecompression = DecompressionMethods.GZip;

    using (HttpWebResponse response = (HttpWebResponse) await request.GetResponseAsync())
    using (Stream stream = response.GetResponseStream())
    using (StreamReader reader = new StreamReader(stream))
    {
        var html = reader.ReadToEnd();
        log.LogInformation(html);
    }
}

[FunctionName("Durable_Starter")]
public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequest req, [DurableClient] IDurableClient starter, ILogger log)
{
    log.LogInformation("C# HTTP trigger function processed a request.");

    string instanceId = await starter.StartNewAsync("Durable_Orchestrator");

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

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

    return checkStatusResponse;
}


[FunctionName("Durable_Orchestrator")]
public async Task RunOrchestrator([OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log)
{
    var message = await context.CallActivityAsync<string>("HelloWorld", "Thiago");
    log.LogInformation(message);
}

[FunctionName("HelloWorld")]
public string HelloWorldActivity([ActivityTrigger] string name)
{
    return $"Hello {name}!";
}
[FunctionName(“Function1”)]
公共异步任务运行([TimerTrigger(“0*/1****”)TimerInfo myTimer,ILogger日志)
{
log.LogInformation($“C#计时器触发器函数在:{DateTime.Now}执行”);
变量url=”http://localhost:7071/api/Durable_Starter";
HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(url);
request.AutomaticDecompression=DecompressionMethods.GZip;
使用(HttpWebResponse=(HttpWebResponse)wait request.GetResponseAsync())
使用(Stream=response.GetResponseStream())
使用(StreamReader=新StreamReader(stream))
{
var html=reader.ReadToEnd();
登录信息(html);
}
}
[FunctionName(“耐用启动机”)]
公共异步任务运行([HttpTrigger(AuthorizationLevel.Anonymous,“get”,“post”)]HttpRequest请求,[DurableClient]IDurableClient启动器,ILogger日志)
{
LogInformation(“C#HTTP触发器函数处理了一个请求。”);
string instanceId=await starter.StartNewAsync(“持久的协调器”);
LogInformation($“启动了ID为“{instanceId}”的业务流程”;
var checkStatusResponse=starter.CreateCheckStatusResponse(req,instanceId);
返回checkStatusResponse;
}
[FunctionName(“持久的协调器”)]
公共异步任务RunOrchestrator([OrchestrationTrigger]IDurableOrchestrationContext,ILogger日志)
{
var message=await context.CallActivityAsync(“HelloWorld”、“Thiago”);
日志、登录信息(消息);
}
[函数名(“HelloWorld”)]
公共字符串HelloWorldActivity([ActivityTrigger]字符串名称)
{
return$“Hello{name}!”;
}

谢谢。但是Http的东西是不需要的,是吗?持久化启动程序可以启动计时器触发,调用持久化编排器,后者调用HelloWorld。我知道你想要的是相反的。调用持久编排器的时间触发器