Attempt to send message from Azure Function to Azure SignalR fails with 403 forbidden
Macháček Martin
211
Reputation points
Hi,
I'm using Azure SignalR in serverless mode. I've an Azure Function which receives events from Event Hub and sends messages to Azure SignalR.
[Function(nameof(EventHubEventsHandler))]
[SignalROutput(HubName = "userevents", ConnectionStringSetting = "SignalRConnectionSetting")]
public async Task<List<SignalRMessageAction>> Run([EventHubTrigger("userschanged", Connection = "EventHubConnectionSetting")] EventData[] events)
{
var messages = new List<SignalRMessageAction>();
foreach (EventData @event in events)
{
try
{
messages.Add(new SignalRMessageAction("userChanged")
{
Arguments = new[] { "user changed" },
});
}
catch (Exception ex)
{
...
}
}
return messages;
}
The connection string SignalRConnectionSetting
in Azure Function App settings is defined like Endpoint=https://xxx.service.signalr.net;AccessKey=yyy;Version=1.0;
Azure Function is triggered successfully, but in Application Insights I see that the attempt to send message to Azure SignalR fails with 403 forbidden.
What I see in the logs:
GET https://xxx.service.signalr.net/api/v1/auth/accessKey
Result code: 200
POST https://xxx.service.signalr.net/api/hubs/userevents/:send?api-version=2022-06-01
Result code: 403
System.Net.Http.HttpRequestException
Exception while executing function: Functions.EventHubEventsHandler Azure SignalR service runtime error. Request Uri: https://xxx.service.signalr.net/api/hubs/userevents/:send?api-version=2022-06-01 Response status code does not indicate success: 403 (Forbidden)
I've no clue what can be wrong.
Sign in to answer