简体   繁体   中英

The listener for function 'SignalR' was unable to start. Azure function binding with signalr

I'm developing an application where IOT devices are connected with the Azure IOT Hub. and its realtime data can be visible on the web view. However, I'm facing an error, I'm trying to bind the data Azure function with SignalR, but when I run the application I receive the following error message.

The listener for function 'SignalR' was unable to start. Microsoft.Azure.EventHubs.Processor: Encountered error while fetching the list of EventHub PartitionIds. System.Private.CoreLib: The link address '$management' did not match any of the expected formats.

Error Description Image

I've tried everything to fix it but failed every time. I'd really appreciate if someone would help me find the solution to this problem.

Here is the script I'm using from this link

Here is my SignalR.cs class

 public static class SignalR
{
    [FunctionName("SignalR")]
    public static async Task Run(
        [IoTHubTrigger("messages/events", Connection = "IoTHubTriggerConnection", ConsumerGroup = "$Default")]EventData message,
        [SignalR(HubName = "broadcast")]IAsyncCollector<SignalRMessage> signalRMessages,
        ILogger log)
    {

        var deviceData = JsonConvert.DeserializeObject<DeviceData>(Encoding.UTF8.GetString(message.Body.Array));
        deviceData.DeviceId = Convert.ToString(message.SystemProperties["iothub-connection-device-id"]);


        log.LogInformation($"C# IoT Hub trigger function processed a message: {JsonConvert.SerializeObject(deviceData)}");
        await signalRMessages.AddAsync(new SignalRMessage()
        {
            Target = "notify",
            Arguments = new[] { JsonConvert.SerializeObject(deviceData) }
        });
    }
}

Here is my SignalRConnection.cs class

    public static class SignalRConnection
{
    [FunctionName("SignalRConnection")]
    public static SignalRConnectionInfo Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
        [SignalRConnectionInfo(HubName = "broadcast")] SignalRConnectionInfo info,
        ILogger log) => info;
}

Here is my local.settings.json file

    {
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "AzureSignalRConnectionString": "",
    "MSDEPLOY_RENAME_LOCKED_FILES": 1,
    "IoTHubTriggerConnection": ""
  },
  "Host": {
    "LocalHttpPort": 7071,
    "CORS": "*"
  }
}

for IoTHubTriggerConnection, I'm using the connection string of iothubjohnsoncontrol (displayed in image below).

IOT Hub Keys Image

for AzureSignalRConnectionString, I'm using the connection string of signalrjohnsoncontrol (displayed in image below).

SignalR Keys Image

Could you please check if you have given EventHub Compatible name and EventHub compatible connections string from here在此处输入图片说明

Please try replacing messages/events with EventHub-Compatible name and IoTHubTriggerConnection as EventHub compatible endpoint from portal.

Almost similar discussion here : https://github.com/Azure/azure-event-hubs-dotnet/issues/103

I have a usecase like that to Push Iot data to Azure data explorer and this is what my Function looks like在此处输入图片说明

Iot Hub Connection string which is EventHub compatibale在此处输入图片说明

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM