1

I have the following services implemented on Azure:

  • 1x Azure SignalR Service (Serverless) ASRS
  • 2x Azure Functions (Serverless) HubFuncDown & HubFuncUp

On the ASRS I have defined TWO UpStream URLs, one to HubFuncDown Azure Function and the other to HubFuncUp. Using the URL pattern defined in the docs:

enter image description here

HubFuncDown Contains the following method which instructs the device app to disable itself:

[FunctionName(nameof(DisableDevice))]
public async Task DisableDevice([SignalRTrigger] InvocationContext invocationContext, string deviceId, ILogger logger) {
    await Clients.User(deviceId).SendAsync(DisableDeviceTarget, new NewMessage(invocationContext, deviceId));
}

And HubFuncUp Contains the following method:

[FunctionName(nameof(DeviceDisabled))]
public async Task DeviceDisabled([SignalRTrigger] InvocationContext invocationContext, string deviceId, ILogger logger) {
        // .. Updates DBContext, sends alerts etc
}

I'm trying to tell HubFuncUp that this client is now in a disabled state, the code to do that on the (UWP) client is:

var connection = new HubConnectionBuilder()
   .WithUrl("https://hubfuncup.azurewebsites.net/api", options => {
       options.AccessTokenProvider = () => Auth();
})
.ConfigureLogging(logging => {
    logging.AddProvider(new SerilogLoggerProvider());
    logging.SetMinimumLevel(LogLevel.Debug);
})
.WithAutomaticReconnect(new RetryPolicy())
.Build();

And to tell HubFuncUp of the state:

await connection.InvokeAsync("UpdateDeviceState", new DisabledDeviceMessage { DeviceId = 123, State = States.Disabled });

But each time I'm receiving a 404 Error from the call to InvokeAsync("UpdateDeviceState"..). It seems no matter what I do I cannot connect the one ASRS to two Azure Functions using multiple Upstream URLs.

Am I correct in thinking I need to utilise a seperate Azure SignalR Service (which doubles my cost) or can I connect the two Functions to the one SignalR Service via routing on the Upstream URLs?

Leigh
  • 1,495
  • 2
  • 20
  • 42
  • The interim solution for now is to use a seperate `ASRS` for each function. The client connects to both `ASRS`, listens for messages from `HubFuncDown` and responds to the second `ASRS` which routes the response to the `HubFuncUp` function. – Leigh Feb 18 '22 at 10:30

0 Answers0