Azure Application Gateway - How to control traffic for different application - azure

I am creating an application gateway and that will be a single point of entry for my multi tenant application. That means I will have multiple application request on this application gateway and then I need to redirect to backend pool. If I will have one application A deployed in app service A then it will listen at port 80 of app gateway. Similar if I have another application, I can expose it using similar way on different port. How can I achieve it. I tried creating multiple rules but not working.

If I read your question correctly, you want multiple app services, each on a potentially different port, to be served by a single application gateway. And it sounds possible you might want to make requests to that application gateway on different port. Sound right?
If so, then what you need to do is something along these lines:
Set up a backend pool for each app service.
Set up an HTTP setting for each backend pool, specifying port, session affinity, protocol, etc. - This will be the port that your App Service takes requests on.
Create a front end IP configuration to expose a public and/or private IP address
Create a listener for each app service, and port that you want to support. This will be the port you want the client requests to use. You can do two listeners per service to allow 80 & 443 (HTTP & HTTPS) traffic, for example.
Create a rule to connect each listener to its backend pool and HTTP setting combination
Optional - set up health probes that target monitoring endpoints based on an URL and a specific HTTP setting entry

Related

Address of REST API hosted on service fabric

Suppose I have a stateless service running in service fabric and I have 5 nodes in my service fabric cluster. Now since each node in the cluster has an instance of stateless service, this means there will be 5 instances of my stateless service on 5 nodes.
But since each node has a different IP address and port number where it can host the service, there can be multiple different endpoint addresses at which my service is hosted.
Now my service is actually a REST API providing some crud functionalities.
Now I have set the port no to be 8080 in servicemanifest.xml file.
Now my question is, does setting port no specifically in servicemanifest.xml disable dynamically selection of port? Will this make every node on cluster use same port i.e. 8080 in endpoint address of the service?
Another question is that if the service is shifted to some another machine and deployed there and having 8080 as port can cause conflict if some other service on its cluster is already using the same port i.e. 8080?
How will we let the client know at which endpoint address my API is hosted?
Does setting port no specifically in servicemanifest.xml disable
dynamically selection of port?
Yes it does
Will this make every node on cluster use same port i.e. 8080 in
endpoint address of the service?
Yes, if you set instance count to -1 all nodes will run the service at that port. You can call them by using the external load balancer (external to service) or directly on the node IP / localhost (service to service).
If the service is shifted to some another machine and deployed there
and having 8080 as port can cause conflict if some other service on
its cluster is already using the same port i.e. 8080?
There will never be more that 1 instance of 1 stateless service on 1 node, within the same application. SF takes care of this. However, if another service is using the port, it cannot be used by another service unless you use a server that supports port sharing like http.sys.
To deal with port conflicts, have a look at the built-in reverse proxy or Traefik. Using a reverse proxy takes away the pain of managing ports, and allows you to call your service by its application and service name.

Azure: Route subdomain traffic to different backend port

I have multiple sites hosted on the same machine in Azure on different ports:
foobar.com:8000
foobar.com:8001
foobar.com:8002
etc
I would like to address these by subdomain using a reverse proxy;
aaaa.mysite.com ----> foobar.com:8000
bbbb.mysite.com ----> foobar.com:8001
cccc.mysite.com ----> foobar.com:8002
Is it possible to do this in Application Gateway? It only seems to cater for different paths (not subdomains) and doesn't allow ports to be specified for backends.
Is there another Azure feature that allows for this (e.g. Front Door)?
As your requirement to address them by subdomains in APP GW, you could use multi-site hosting.
There are three common mechanisms for enabling multiple site hosting
on the same infrastructure.
Host multiple web applications each on a unique IP address. Use host
name to host multiple web applications on the same IP address. Use
different ports to host multiple web applications on the same IP
address.
For example, you want aaaa.mysite.com ----> foobar.com:8000. The main configuration will be like this: create a multi-site listener, use frontend port 80 and hostname aaaa.mysite.com in this multi-site listener. HTTP setting should specify the port 8000. Make sure the listener is listening on port 80 and HTTP setting configure your custom port for your backend websites.
In this case, you will create 3 Listeners with on same port 80,and specify the hostnames and create 3 HTTP settings, and create rules with corresponding Listener and HTTP settings and backend pool.
The Azure front door also has URL-based routing and Multiple-site hosting ability. Refer to this document.
Update
Backend pools
Create one backend pool and set your Azure VM as the backend in the backend pool.
Listeners
Click multi-site to create a multi-site listener then save it. You need three listeners for your host name.
Type the subdomains as the host name
Health probes
Add a health probe and checkbox pick host name from backend http settings.
HTTP settings
Add three HTTP settings and specify the custom port on each of HTTP settings.
Rules
Add three basic rules with corresponding Listener and HTTP settings and backend pool.

How to start self-hosted OWIN Web API listening to a range of ports?

I'm running an Azure Worker Role that with self-hosted OWIN Web API
Currently, the host is initialized with a single URL like so:
var options = new StartOptions(endpoint);
_app = WebApp.Start<Startup>(options);
The endpoint has a port hard-coded in it. I'd like to have it listen on a range of ports.
My real issue is as follows:
My Web API host is not getting round-robined by Azure's load balancer. I believe this is because the default ("none") affinity setting uses SourceIP, Source Port, Target IP, Target Port, Protocol type to perform its load balancing. However, the clients to my Web API (in the thousands) are always the same clients - they connect every minute to perform some operations. Thus, these client's ports and IP's don't change. My listening port and IP do not change since the host is hard-coded to a port. All of the requests from these clients are getting round-robined to the same instance all the time. I've verified this over and over and over again. My first worker role instance gets all the traffic, as soon as 2nd instance is rebooted. 2nd instance never kicks in.
I would like to try to have my OWIN hosted Web API listen on a range of ports. Is this the right approach? If so, how can this be done?

Endpoint configuration for Service Fabric

I deployed an app on Service Fabric and there's an HTTP listener spawned inside. How can I configure the listening URL in relation to app/cluster?
More precisely, is there any way to build this URL inside the app by retrieving some environment/role parameter ?
Suppose my cluster is called "test", then it will be available at: test.northeurope.cloudapp.azure.com. If I have an app called "Sample" for which I configured an endpoint called "SampleTypeEndpoint" inside ServiceManifest.xml, what would be the complete URL my app would listen to?
The endpoints you configure in ServiceManifest.xml right now fulfill two purposes:
Allow Service Fabric to provide a unique port from an application port range, if you don't need a well-known port.
When opening a web server that uses http.sys, allow Service Fabric to set up URL ACLs for a random port or a well-known port (80, 443, etc) and certificate ACLs for HTTPS.
That's basically it. The actual address on which you open a listener is up to you to determine. Typically, you open a listener on the node IP and use a NAT for ingress traffic on a domain name. In Azure, the NAT is the Azure Load Balancer which is automatically configured to accept traffic on your cluster's VIP as well as the .region.cloudapp.azure.com domain.
Here's a more thorough overview of how this works on Service Fabric cluster in Azure: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-connect-and-communicate-with-services/

service fabric URL routing

I am using the Azure Load Balancer with Azure service fabric to host multiple self host web applications, I'd like to create a rule that allows me to route based on the users URL request.
So for example if a user navigates to :
http:// domain.com/Site1 then the rule would route to:
http:// domain.com**:8181**/Site1 within the cluster
if the user navigates to:
http:// domain.com/Site2 then the rule would route to:
http:// domain.com**:8282**/Site2 within the cluster
Is this possible with azure service fabric/load balancer?
The Azure Load Balancer only forwards traffic it receives on a port to a node in your cluster on another port (can be the same port or a different internal port). It operates on Layer 4 (TCP, UDP) so it doesn't know anything about HTTP or URLs (although it does allow HTTP probes).
Here are a couple options for multiple web sites:
If you want your web sites hosted internally on different ports (8181 and 8282), then you'll need something else to do URL routing. Azure Traffic Manager or Azure Application Gateway are possible options that would run outside your cluster. Your Azure Load Balancer would need to open a port for each web site, but the benefit is this way you can run your web sites on dedicated nodes and the ALB would automatically route traffic to the appropriate nodes based on which ports are open.
Alternatively, you can set up your own stateless routing service that runs inside your cluster.
Or you can skip routing altogether and just host all of your websites on port 80/443. As long as you're using an http.sys-based web host, which includes Katana, ASP.NET Core 1 WebListener, or anything you build on HttpListener, you can use the same port for all your websites and let the underlying http server route according to either a URL path or hostname, both of which are supported.

Resources