Joey
Joey
CC#
Created by Joey on 3/9/2025 in #help
✅ SignalR trigger for Azure Function (isolated) does not trigger.
Trying to set up a SignalR trigger that recieves a message from the client. The negotiate work fine, and the connection gets established. I see the message being sent from the client as well, but my function never triggers. The message that gets sent: {"arguments":["Hello from client"],"invocationId":"0","streamIds":[],"target":"sendMessage","type":1} Azure function:
c#
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

namespace HueCue.API;

public class Api(ILogger<Api> logger)
{
private const string HubName = "ChatRoom";

[Function("negotiate")]
public string Negotiate(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")]
HttpRequestData req,
[SignalRConnectionInfoInput(HubName = HubName, ConnectionStringSetting = "AzureSignalR")]
string connectionInfo)
{
logger.LogInformation($"SignalR Connection data requested: {connectionInfo}");

return connectionInfo;
}

[Function(nameof(SendMessage))]
public void SendMessage(
[SignalRTrigger(HubName,"messages", nameof(SendMessage), ConnectionStringSetting = "AzureSignalR")]
SignalRInvocationContext invocationContext)
{
// Extract the message from the arguments
var content = invocationContext.Arguments?.Length > 0
? invocationContext.Arguments[0]?.ToString()
: "(no content)";

logger.LogInformation($"SignalR Message received: {content}");
}
}
c#
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

namespace HueCue.API;

public class Api(ILogger<Api> logger)
{
private const string HubName = "ChatRoom";

[Function("negotiate")]
public string Negotiate(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")]
HttpRequestData req,
[SignalRConnectionInfoInput(HubName = HubName, ConnectionStringSetting = "AzureSignalR")]
string connectionInfo)
{
logger.LogInformation($"SignalR Connection data requested: {connectionInfo}");

return connectionInfo;
}

[Function(nameof(SendMessage))]
public void SendMessage(
[SignalRTrigger(HubName,"messages", nameof(SendMessage), ConnectionStringSetting = "AzureSignalR")]
SignalRInvocationContext invocationContext)
{
// Extract the message from the arguments
var content = invocationContext.Arguments?.Length > 0
? invocationContext.Arguments[0]?.ToString()
: "(no content)";

logger.LogInformation($"SignalR Message received: {content}");
}
}
47 replies
CC#
Created by Joey on 8/11/2024 in #help
Unable to debug newly created Azure Function app (.NET 8.0 Isolated)
No description
2 replies