Websockets using REST API

teaTester 20 Reputation points
2024-01-16T06:23:04.5566667+00:00

I have a some WebSocket implementation in my application and I also many other REST endpoints implemented in the same app. Can i facilitate this by creating a REST API.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,945 questions
0 comments No comments
{count} votes

Accepted answer
  1. Grmacjon-MSFT 19,151 Reputation points Moderator
    2024-01-17T06:56:21.0166667+00:00

    Hi @teaTester the short answer is yes.

    however, are you referring to implementing WebSocket with a REST API in Azure App Service? is this Windows or Linux application?

    Here are a few steps you can follow to get started generally:

    • Create a REST API facade that provides a consistent interface to access the functionality in your app. The REST API can route requests to either the WebSocket endpoints or internal REST endpoints as appropriate.
    • Use Azure API Management to create the REST API layer. This makes it easy to define the REST APIs and route requests to the backend. API Management has native support for WebSockets as well.
    • Structure your app into separate services - one focused on the real-time WebSocket functionality, and one focused on REST APIs. Use an internal communication mechanism like queue or events to connect them.
    • Use a gateway like Azure Application Gateway to handle routing incoming requests to the appropriate endpoints.
    • Leverage Azure Functions to implement any simpler REST APIs, and have them trigger events to integrate with the backend.
    • Use conventions and documentation to provide a unified view of the WebSocket and REST endpoints from the client's perspective.

    Hope that helps.

    Grace

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.