9

I have the same question as this guy: can I run my SignalR hub through the Azure API management service?

enter image description here

I cannot seem to configure it in the service: it only allows me to forward HTTP/HTTPS traffic. That matches the answer of the person in the forum post. I followed the link down to the Microsoft forum, but it seems the question wasn't followed up there. Since the response was from 2014, I thought - maybe it is possible now.

timtos
  • 2,225
  • 2
  • 27
  • 39
Jochen van Wylick
  • 5,303
  • 4
  • 42
  • 64

4 Answers4

5

websocket is currently not supported in Azure API Management. Please feel free to raise a feature request: http://feedback.azure.com/forums/248703-api-management/filters/new

Miao Jiang
  • 635
  • 3
  • 4
3

As we know, the Azure API Management still doesn't support WebSockets

Dec 6, 2016:
Rest assured we still have this request in mind and are continually reviewing it. Please keep your feedback coming!

If you are using Azure SignalR Service then you can follow the way described by @lazizanie because your SignalR service should only provide a negotiate endpoint:

enter image description here

Let's say you have the Hub named myHub in ASP.NET Core 3.1

app.UseEndpoints(endpoints => endpoints.MapHub<Hub>("/myHub"));

Then add operation in API management URL=POST /myHub/negotiate with negotiateVersion query param

or use JSON editor and add it to paths

"/myHub/negotiate": {
    "post": {
        "summary": "SignalR negotiate ",
        "operationId": "signalr-negotiate",
        "parameters": [{
            "name": "negotiateVersion",
            "in": "query",
            "schema": {
                "type": ""
            }
        }],
        "responses": {
            "200": {
                "description": null
            }
        }
    }
}

For the Backed set host of your SignalR service like https://myHubSignalR.westeurope.cloudapp.azure.com

Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116
  • 1
    websockets are now supported in APIM: learn.microsoft.com/en-us/azure/api-management/websocket-api. Does that mean we should be able to leverage APIM to establish connections with signalR service? – NSjonas Feb 24 '22 at 15:14
  • @NSjonas yes, we have already moved to it – Roman Marusyk Feb 25 '22 at 09:55
2

It depends, websockets are not supported, but if you use an azure signalr ressource, only the negotiate request,; which is a basic post to your hub, has to go through your APIM, and the rest of the coms (the websocket requests) will be directly with the azure signalr ressource.

lazizanie
  • 493
  • 3
  • 15
1

API Management supports Web Sockets now.

  1. Navigate to the API Management instance in the Azure Portal
  2. Add Api
  3. Under Define a new API, select WebSocket
  4. In the dialog box, select Full and complete the required form fields
  5. Click create

https://learn.microsoft.com/en-us/azure/api-management/websocket-api?tabs=portal

(WebSocket APIs are not supported yet in the Consumption tier.)

jasdefer
  • 757
  • 12
  • 24
  • That's good to know. Unfortunately, it requires setting up a separate WebSocket API endpoint in API Management. AFAIK, this will not be a solution if you use SignalR embedded in your API (i.e. have a single operation like `/hub` on the same api). – Juliën Mar 30 '23 at 10:00