configuring a dynamic websocket endpoint in azure apim

143 views Asked by At

I am trying to configure a azure apim websocket endpoint .

Below are the steps I tried

  1. created a websocket endpoint
  2. configured the settings as below websocket url : wss://app.square.ai:5001/CustomerActionHub/51 Url suffix : exam/CustomerActionHub/51

The above steps are working fine when I create it as static.

Now I have to configure in such a way where the above value 51 will change dynamically. How do I achieve that

below is the setting i tried but its throwing error

steps tried in apim

1

There are 1 answers

4
Ikhtesam Afrin On BEST ANSWER

Now I have to configure in such a way where the above value 51 will change dynamically. How do I achieve that

You can use the below policy to accept the value as a query parameter while sending the request.

<inbound>
    <base  />
    <set-backend-service  base-url="@{ return "wss://app.square.ai:5001/CustomerActionHub/"+context.Request.Url.Query.GetValueOrDefault("CustomerId");}"  />
</inbound>

You can also use rewrite-uri but in case of WebSocket APIs, its not giving expected result. AFAIK, it might be because WebSocket APIs in Azure APIM is currently in public preview as per this MS Docs.

In my case I have used above policy to establish a connection with Azure PubSub Service and I am sending Hub Name in query parameter as shown below.

enter image description here

enter image description here

As a workaround, you can use the above given policy and meanwhile you can also check with the Product team for any further details.