Azure AppGateway path route to multiple app service webapps? - azure

I have a WAF App Gateway
appgateway.eastus.cloudapp.azure.com.
And 2 App Service web apps
api-service.azurewebsites.net
web-ui.azurewebsites.net
Both these app services are completely different app and one of them is a JS Application and other is Java Application. Both these belong to single App Service Plan.
I'm trying to route App Gateway based on path to these app services
Eg:
/api/* -> route to backend pool of api app service
/* -> route to backend pool of web app service
Is it possible with App Gateway to send in the traffic based on path to the app services?

Yes, this is possible. You need to place each web app in seperate backend pool. Then create path based rule to achieve your ask.
If you face any difficulty during the implementation, let me know.

Related

Access restriction for app service holding ocelote api gateway project

I have deployed few .net core microservices along with ocelot api gateway and react application using azure app services.
Every app service is running in its own app service plan and subnet with vnet integration enabled. I am able to restrict direct access to microservices through service end points.
The problem is, I want to restrict access to api gateway app service so that it only accepts traffic from react application app service. Whenever I try to do so through vnet integration and service endpoints, my application stops working with 403 IP forbidden.
Is there any way I can achieve the desired result?

Restrict access to microservice deployed in app service

I am using Azure App service to deploy my microservice, those are exposed via APIM consumption mode.
I have deployed 2 microservices in separate app service, traffic of only one app service is allowed from APIM, whereas other app service can be accessed by first app service. How can I achieve this, I am new to Azure.
APIM -> App service instance 1 -> App service instance 2

How to add Azure App Service redundancy using Application Gateway?

what is the recommended best practice for using Azure Application Gateway with redundant app services (in either different regions or availability sets)? I've had some issues recently where our app service would occasionally go down for a couple minutes (due to maintenance in msft's data center) and I'd like to have our app gateway redirect load to another instance or app service when this happens.
Currently traffic is handled as such: public request -> app.example.com -> app gateway -> app.example.com -> backend app service.
I've been unable to add a second app service because when I attempt to do so I get the error "Hostname is already being used in the following App: myappservicename. Please remove the Hostname from myfirstappservice, and try again" when I attempt to add the custom domain to a second app service. It seems my custom domain would need to be added to each individual app service in order for traffic to be routed properly to my backend web app. Or is there another way I should have traffic configured?
You should bind your custom domain to your app gateway only and add your two app services into a backend pool so that the traffic could be:
public request -> app.example.com -> app gateway ->backend pool(handled by one of your 2 app services)
which meets your requirement.

Application Gateway Url Routing to multiple App Services

I have several app services that I want to use application gateway to sit in front of and route traffic to using URL Routing. For example:
api1-app-service
api2-app-service
website1-app-service
I would like to use the Application Gateway with a custom domain in front of it, and route the traffic like this:
test.app.com/api/something -> api1-app-service
test.app.com/api/different -> api2-app-service
test.app.com/ -> website1-app-service
I setup 3 different backend pools and a url routing rule that looks like this:
rule1 | /api/something* | backendPool1
rule2 | /api/different* | backendPool2
default rule | backendPool3
The problem I am having is that the direction here (https://blogs.msdn.microsoft.com/waws/2017/11/21/setting-up-application-gateway-with-an-app-service-that-uses-azure-active-directory-authentication/) says that the app service has to be setup with the custom domain that you are pointing to the application gateway (test.app.com in my example), but I can't configure test.app.com to go to multiple app services. I get an error that the hostname is already mapped to another app service (which is true, when trying to map to api2-app-service test.app.com is configured to api1-app-service). Is is possible to setup an application gateway in front of multiple app services?
It's possible to setup an application gateway in front of multiple app services.
If you want custom domains with your web app service, you could configure different custom domains in different App services. Probably, if you'd like to use the same custom domain, you could deploy multiple Applications in the same web app service with different virtual paths.
If you do not want custom domains in multiple App Services, you could use the default hostname *.azurewebsites.net. If so, the Application Gateway frontend will direct the client request to different backend pools based on the different routing rules. You could configure for the backend HTTP setting using -PickHostNameFromBackendAddress.
Ref: Hosting multiple sites in one Azure WebApp and create an application gateway with path-based routing rules.
After researching all day, I am fairly sure this isn't possible using just an Application Gateway and app services. I am going to containerize my app and then use the application gateway and see if that does what I want it to.

Configuring Azure Application Gateway to Azure web app to route requests by path

I have two web apps (webapp1 and webapp2). I would like to use Application Gateway features where can route using path based redirect.
http://mywebsite/login1 redirect to webapp1
http://mywebsite/login2 redirect to webapp2
Is this possible it possible to do this with Application gateway if so can you please give link or direction on how to do this for web apps prespective
Yes, it is. You can use path-based routing in the Application Gateway to do the job. Here is the link:
Application Gateway URL Routing
The main idea is that you can use the routing rules to point to a specific backend pool. That backend pool will point to whatever servers you want handling that request.
Is this possible it possible to do this with Application gateway
Sure. If you want to do that with Azure WebApp service. But there are two things that we need to do:
1.Make sure that the application root path is the same as you mapped in the Application Gateway. For instance:
if you want route http://mywebsite/login1 -> webapp1
Your webapp1 application root path(home page) should be :http:///login1 You can do quick config at your app service - > Application settings -> Virtual applications and directories:
2.Two custom health prob is needed for Azure web apps , we could use PS script to create them since it seems there is no way to create them on Azure portal.
For more detail information, please refer to this blog.

Resources