Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core Azure Signal R无服务器非连接触发器与Azure函数(传统型号)_Asp.net Core_Azure Functions_Signalr_Serverless - Fatal编程技术网

Asp.net core Azure Signal R无服务器非连接触发器与Azure函数(传统型号)

Asp.net core Azure Signal R无服务器非连接触发器与Azure函数(传统型号),asp.net-core,azure-functions,signalr,serverless,Asp.net Core,Azure Functions,Signalr,Serverless,我将Azure信号器服务与Azure功能结合使用,我有以下代码: public class SignalRHubFunction { [FunctionName("SignalRConnected")] public async Task Run([SignalRTrigger("myhubname", "connections", "connected", Conne

我将Azure信号器服务与Azure功能结合使用,我有以下代码:

    public class SignalRHubFunction
    {
        [FunctionName("SignalRConnected")]
        public async Task Run([SignalRTrigger("myhubname", "connections", "connected", ConnectionStringSetting = "AzureSignalRConnectionString")] InvocationContext invocationContext, ILogger logger)
        {
            logger.LogInformation($"{invocationContext.ConnectionId} connected");
        }
    }
我很难触发“未连接”事件。仅使用基于类的模型提供示例。 而且对我没有什么帮助

文档告诉我
SignalRTrigger
构造函数的类别参数应该是:连接消息。 所以我使用连接

必须将此值设置为要触发的功能的消息类别。类别可以是以下值之一: 连接:包括已连接和已断开连接的事件 消息:包括除连接类别中的事件外的所有其他事件

我真的不明白文档对事件参数的含义

必须将此值设置为要触发功能的消息事件。对于messages类别,事件是客户端发送的调用消息中的目标。对于连接类别,仅使用已连接和已断开连接

我猜他们是说你可以在连接的和断开的之间进行选择

然而,上面的代码永远不会触发。有什么想法吗?

原始答案:

要使SignalRigger工作,需要为SignalR中的函数设置webhook

当您使用SignalRTrigger部署函数时,它会做两件额外的事情:


  • 创建webhook:
    https://

    此代码段有效。

    [FunctionName("OnConnected ")]
    public async Task OnConnected ([SignalRTrigger("YourHub", "connections", "connected ")]
    InvocationContext invocationContext, ILogger logger)
    {
        logger.LogInformation($"{invocationContext.ConnectionId} has connected");
    }
    
    还要在Azure信号器设置中配置上游URL

    <Function_App_URL>/runtime/webhooks/signalr?code=<API_KEY>
    
    /runtime/webhooks/signer?代码=


    Function\u App\u URL
    可以在Function App的概览页面上找到,而
    API\u键
    是由Azure Function生成的。您可以从Function App的App keys blade中的signalr_扩展获取
    API_密钥。

    我不会将此标记为答案,因为它不是。但我最终使用了Azure团队自己建议的EventGrid触发器:。我仍然想知道如何使用传统模型触发这些事件。我也无法通过这种方式创建组或向组中添加客户端。可能会有帮助: