Search code examples
azureazure-functionssignalrazure-signalr

IS there some how to specify dinamically the Hub Name of Azure SignalR at the negotiate of Azure Serverless Solution?


using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Extensions.SignalRService;

namespace TheNameSpace
{
    public static class Function
    {
        [FunctionName("Negotiate")]
        public static SignalRConnectionInfo Negotiate(
            [HttpTrigger(AuthorizationLevel.Anonymous, Route = "v1/Negotiate")] HttpRequest req,
            [SignalRConnectionInfo(HubName = "serverless")] SignalRConnectionInfo connectionInfo)
        {
            return connectionInfo;
        }
    }
}

This is the function to negotiate - You will find this sample in many others portals or sources. Yes, it works good! But I'd like to specify dynamically the HubName.

On the example above, it's hardcoded and I think it's not possible to be dynamic. I'd like something like HubName = Req.Query("HubName")

How to archive it ?


Solution

  • Use the following:

    [SignalRConnectionInfo(HubName = "{query.HubName}")]