gpt4 book ai didi

.net-core-3.0 - WebJob .Net Core 3 的 Azure SignalR 绑定(bind)不起作用

转载 作者:行者123 更新时间:2023-12-05 09:12:09 25 4
gpt4 key购买 nike

我有一个 .Net Core 3.0 控制台项目,其中包含 WebJob 函数,该函数具有与 Azure Signal R 的输出绑定(bind)。该应用程序构建正常,但是当我运行它并尝试通过 SignalR 发送消息时,出现以下错误:

{System.MissingMethodException: Method not found: 'System.String Microsoft.Azure.SignalR.AuthenticationHelper.GenerateAccessToken(System.String, System.String, System.Collections.Generic.IEnumerable`1<System.Security.Claims.Claim>, System.TimeSpan, System.String)'.
at Microsoft.Azure.SignalR.Management.RestApiAccessTokenGenerator.Generate(String audience, Nullable`1 lifetime)
at Microsoft.Azure.SignalR.Management.RestApiProvider.GenerateRestApiEndpoint(String path, Nullable`1 lifetime)
at Microsoft.Azure.SignalR.Management.RestApiProvider.GetSendToGroupEndpoint(String groupName, Nullable`1 lifetime)
at Microsoft.Azure.SignalR.Management.RestHubLifetimeManager.SendGroupAsync(String groupName, String methodName, Object[] args, CancellationToken cancellationToken)
at Microsoft.AspNetCore.SignalR.Internal.GroupProxy`1.SendCoreAsync(String method, Object[] args, CancellationToken cancellationToken)
at Microsoft.Azure.WebJobs.Extensions.SignalRService.AzureSignalRClient.SendToGroup(String groupName, SignalRData data)
at Microsoft.Azure.WebJobs.Extensions.SignalRService.SignalRAsyncCollector`1.AddAsync(T item, CancellationToken cancellationToken)
at InSysWebJobP300DataProcessor.Helper.ProcessMinuteData(Message message, ConnectionMultiplexer redisConnection, IAsyncCollector`1 signalRMessages, ILogger log) in E:\InergySystems\GitHub\InSysCore\InSysWebJobP300DataProcessor\Helper.cs:line 125}

SignalR 服务在 Program.Main 中注册:

static void Main(string[] args)
{
var builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddAzureStorageCoreServices();
b.AddServiceBus().AddSignalR();
});
builder.ConfigureLogging((context, b) =>
{
b.ClearProviders();
b.AddConfiguration(context.Configuration.GetSection("Logging"));
if (context.HostingEnvironment.IsDevelopment())
{
b.AddConsole();
}
});

var host = builder.Build();
using (host)
{
host.Run();
}
}

我有一个具有以下签名的函数:

[FunctionName("ProcessMinuteData")]
public async Task RunAsync([ServiceBusTrigger("data", Connection = "AzureWebJobsServiceBusConnection")]Message message, [SignalR(HubName = "insyshub")] IAsyncCollector<SignalRMessage> signalRMessages, ILogger log)

从服务总线接收到的消息处理得很好,但是尝试使用以下命令通过 SignalR 推送消息会导致上述错误:

await signalRMessages.AddAsync(new SignalRMessage
{
GroupName = "GroupName",
Target = "targetMethod",
Arguments = new[] { JsonConvert.SerializeObject(message) }
});

请注意,该应用不需要通过 SignalR 接收消息,只需将它们推送出去即可。

我安装了以下 NuGet 包:

<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.14" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.5" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.0.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.14" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.1" />

最佳答案

似乎从 Microsoft.Azure.SignalR 1.2.0 开始,如果您想使用我在问题中详细说明的方法,您现在需要包含 Microsoft.Azure.SignalR.Management。

在 1.2.0 之前,您不需要包含 Microsoft.Azure.SignalR.Management。

关于.net-core-3.0 - WebJob .Net Core 3 的 Azure SignalR 绑定(bind)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58965003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com