基于类的编排 - 找不到例外(.NET Core,Azure函数)

问题描述 投票:0回答:1
Grpc.core.rpcexception:'状态(statusCode =“ Internal”,lidet =“未能使用ID123E757C8A0F7480986A27527525F8877AEEB.YEB.

Inner异常消息:
函数“ abcorchestrator”不存在,被禁用或不是编排函数。附加信息:目前没有编排功能!。”)'

这是我的代码:

[Function(nameof(ClientABCOrchestrator))] public async Task<string> Run( [BlobTrigger("someContainer/{someFileName}", Connection = "connString")] BlobClient clientBlob, string someFileName, [DurableClient] DurableTaskClient client) { var instanceId = ""; try { instanceId = await client.ScheduleNewOrchestrationInstanceAsync(nameof(DocumentProcessingOrchestrator), dmsFileUploaded); } catch (Exception ex) { throw; } }

操纵器代码:

namespace myNS
{
    [DurableTask(nameof(ABCOrchestrator ))]
    public class ABCOrchestrator : TaskOrchestrator<string, string>
    {
        public ABCOrchestrator () {}

        public async override Task<string> RunAsync(TaskOrchestrationContext context, string input)
        {
            // Calling the class based task activity.... 
            var result = await context.CallActivityAsync<bool>(nameof(SomerActivity), input);
        }
    }
}

参考软件包:

<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Core" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.12.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" Version="6.6.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk.Analyzers" Version="1.2.2" />

<PackageReference Include="Microsoft.Extensions.Azure" Version="1.10.0" />
<PackageReference Include="Microsoft.DurableTask.Generators" Version="1.0.0-preview.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.2.2" />
come不再支持基于班级的编排和不支持.NET Core Azure功能的活动? 这些以前从事这些工作,但在包装更新后破裂了。 Orchestrator客户端将成功调用编目。正是在更新包装之前。

要解决错误,请在.csproj中添加
FunctionsEnableWorkerIndexing

FunctionsEnableExecutorSourceGen

<FunctionsEnableWorkerIndexing>false</FunctionsEnableWorkerIndexing> <FunctionsEnableExecutorSourceGen>false</FunctionsEnableExecutorSourceGen>
azure .net-core azure-functions
1个回答
0
投票
也安装

Microsoft.DurableTask.Generators

软件包。
我可以在.NET 8.0隔离的Azure函数中运行基于类的编排。
功能代码:

public static class Function1
{
    [Function("Function1_HttpStart")]
    public static async Task Run(
        [BlobTrigger("container1/{someFileName}", Connection = "connString")] BlobClient clientBlob,
        string someFileName,
        [DurableClient] DurableTaskClient client,
        ILogger log)
    {
        var instanceId = "";

        try
        {
            var input = "FileUploaded"; 
            instanceId = await client.ScheduleNewOrchestrationInstanceAsync(nameof(ABCOrchestrator), input);            
        }
        catch (Exception ex)
        {
            throw;
        }

    }
}

基于类的活动和编排:

[DurableTask(nameof(SayHelloActivity))] public class SayHelloActivity : TaskActivity<string, string> { public override async Task<string> RunAsync(TaskActivityContext context, string input) { return input; } } [DurableTask(nameof(ABCOrchestrator))] public class ABCOrchestrator : TaskOrchestrator<string, string> { public ABCOrchestrator() { } public async override Task<string> RunAsync(TaskOrchestrationContext context, string input) { var result = await context.CallSayHelloActivityAsync(input); return result; } }

PROGRAM.CS:

using FunctionApp;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Azure.Functions.Worker.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = FunctionsApplication.CreateBuilder(args);

builder.ConfigureFunctionsWebApplication();
builder.Services.Configure<KestrelServerOptions>(options =>
{
    options.AllowSynchronousIO = true;
});
builder.Build().Run();

.csproj:

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <FunctionsEnableWorkerIndexing>false</FunctionsEnableWorkerIndexing>
    <FunctionsEnableExecutorSourceGen>false</FunctionsEnableExecutorSourceGen>
  </PropertyGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.7" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.6.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
    <PackageReference Include="Microsoft.DurableTask.Generators" Version="1.0.0-preview.1" />
  </ItemGroup>
可运行该功能:

上计划文件到存储容器:

Console输出:

Functions:

        ABCOrchestrator: orchestrationTrigger

        Function1_HttpStart: blobTrigger

        SayHelloActivity: activityTrigger

For detailed output, run func with --verbose flag.
[2025-02-21T07:49:00.317Z] Worker process started and initialized.
[2025-02-21T07:49:01.252Z] Host lock lease acquired by instance ID '000000000000000000000000F72731CC'.
[2025-02-21T07:49:35.427Z] Executing 'Functions.Function1_HttpStart' (Reason='New blob detected(LogsAndContainerScan): container1/Hello World.txt', Id=1827ccc8-6d36-4a54-b5e8-e02118724e36)
[2025-02-21T07:49:35.434Z] Trigger Details: MessageId: 0a14a271-fc8e-4862-b4ce-1f3b33d24611, DequeueCount: 1, InsertedOn: 2025-02-21T07:49:34.000+00:00, BlobCreated: 2025-02-21T06:39:48.000+00:00, BlobLastModified: 2025-02-21T07:49:31.000+00:00
[2025-02-21T07:49:35.833Z] Scheduling new ABCOrchestrator orchestration with instance ID '301c60dfc2d74ac7b884c9c4d4d5b15f' and 14 bytes of input data.
[2025-02-21T07:49:36.012Z] Executed 'Functions.Function1_HttpStart' (Succeeded, Id=1827ccc8-6d36-4a54-b5e8-e02118724e36, Duration=913ms)
[2025-02-21T07:49:36.083Z] Executing 'Functions.ABCOrchestrator' (Reason='(null)', Id=3ceb14a5-eaf6-4a29-b2ca-ebc415e93340)
[2025-02-21T07:49:36.266Z] Executed 'Functions.ABCOrchestrator' (Succeeded, Id=3ceb14a5-eaf6-4a29-b2ca-ebc415e93340, Duration=198ms)
[2025-02-21T07:49:36.330Z] Executing 'Functions.SayHelloActivity' (Reason='(null)', Id=84e1ddba-2e67-4c57-9c9b-6ac453fb83a1)
[2025-02-21T07:49:36.346Z] Executed 'Functions.SayHelloActivity' (Succeeded, Id=84e1ddba-2e67-4c57-9c9b-6ac453fb83a1, Duration=18ms)
[2025-02-21T07:49:36.405Z] Executing 'Functions.ABCOrchestrator' (Reason='(null)', Id=4d2f75d0-b0ba-48a5-9377-7577a2c42582)
[2025-02-21T07:49:36.425Z] Executed 'Functions.ABCOrchestrator' (Succeeded, Id=4d2f75d0-b0ba-48a5-9377-7577a2c42582, Duration=21ms)

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.