azure - 是否可以在外部项目中定义由 Function App 引用的 Azure Functions?

标签 azure azure-functions azure-durable-functions

我试图在单独的项目中定义一些持久的函数,因为我想将它们作为我的“根项目”中的根编排的子编排启动。

但是,似乎没有找到实际的函数,因为它们是外部项目的一部分。这是已知的限制吗? (我找不到这个文档)

引发的异常如下:函数“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/

相关文章:

Azure功能,灵活的测试和生产队列名称

c# - Azure持久功能: Fan Out vs. Parallel.ForEachAsync

azure - CosmosDB 租赁集合不再自动创建

python-3.x - Azure 组合器函数,用于使用 Python 接收数据并将其写入 Azure Blob 存储

azure-durable-functions - Azure 持久功能 - 端口不可用

azure - 恢复 Azure Durable 函数终止 uri

java - EAR 类加载器看不到位于 jar 中的 ApplicationInsights.xml

azure - 输出绑定(bind)并生成function.json

azure - 检索 Azure 诊断日志

azure - Azure 中并行查询的 CosmosDB SocketException