Hi Behzad, Yes, you can achieve intelligent routing based on the request protocol by leveraging Azure Application Gateway in combination with Azure Container Apps.
Azure Application Gateway is a layer 7 load balancer that allows you to route and balance traffic based on various conditions, including request protocol. You can configure the Application Gateway to listen on both HTTP and TCP ports and then route the traffic to the appropriate backend container based on the protocol of the incoming request.
To accomplish this, you can follow these steps:
- Deploy an Azure Application Gateway in front of your Azure Container Apps environment.
- Configure the Application Gateway with multiple listeners, one for HTTP and another for TCP, specifying the appropriate ports for each.
- Create corresponding backend pools and backend targets for your containers.
- Define rules and routing logic within the Application Gateway to route traffic based on the request protocol. For example, you can set up a rule that forwards HTTP traffic to the backend pool associated with the HTTP container and TCP traffic to the backend pool associated with the TCP container.
- Ensure that the appropriate ports are exposed and correctly handled in your containers' configuration.
By using this these steps, you can have a single hybrid NestJS app running in your Azure Container Apps environment, while Azure Application Gateway intelligently routes the traffic based on the request protocol, eliminating the need for separate containers for HTTP and TCP.
Please be aware that the specific steps and configurations I described. may vary depending on your Azure setup and requirements
I hope this helps?