我试图在单独的项目中定义一些持久的函数,因为我想将它们作为我的“根项目”中的根编排的子编排启动。
但是,似乎没有找到实际的函数,因为它们是外部项目的一部分。这是已知的限制吗? (我找不到这个文档)
引发的异常如下:函数“TestFunction”不存在、已禁用或不是协调器函数。附加信息:当前没有注册任何协调器功能!
为了您的兴趣,一些代码(但没什么特别的):
函数项目
[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);
}
引用项目
public class FunctionDefinitions
{
[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 async Task<string> SayHello([ActivityTrigger] string name, ILogger log)
{
log.LogInformation($"Saying hello to {name}.");
return $"Hello {name}!";
}
}
最佳答案
我做了测试,发现它无法引用外部协调器函数。我收到了与您相同的错误消息,它提示我附加信息:以下是已知的协调器函数:“Function1”。
,Function1 是在同一项目中定义的。
我已经在csproj
文件中引用了外部项目,但它仍然无法检测到外部orchestrator功能。
因此,我建议您在同一个函数应用项目
中定义所有持久函数。
关于azure - 是否可以在外部项目中定义由 Function App 引用的 Azure Functions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64594923/