2

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:

  1. api1-app-service
  2. api2-app-service
  3. 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:

  1. test.app.com/api/something -> api1-app-service
  2. test.app.com/api/different -> api2-app-service
  3. 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?

Mike
  • 1,718
  • 3
  • 30
  • 58

2 Answers2

1

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.

Nancy
  • 26,865
  • 3
  • 18
  • 34
1

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.

Mike
  • 1,718
  • 3
  • 30
  • 58
  • i dont see why you cant route to different app services using the model you described without using custom domains – 4c74356b41 Jan 29 '19 at 05:32
  • Its not possible because, to use the app service with the application gateway, you have to configure the custom domain for the gateway on the app service (i.e. test.app.com). Since I have multiple app services that would sit behind that gateway, they would all need to be configured to use the same custom domain, and that is not allow. – Mike Jan 29 '19 at 06:10
  • why do you think you have to use custom domain? – 4c74356b41 Jan 29 '19 at 06:11
  • because I want my traffic to all go to a custom domain....even if I didn't want traffic to go to a custom domain, I would have to add the application gateway's domain as a custom domain on each app service.... – Mike Jan 29 '19 at 22:00
  • I have a CNAME on my domain that is pointed to the application gateway, but the app services will not accept traffic without having that Custom Domain added (has to do with how App Services routing is setup). Even though the domain is pointed to the app gateway, the app services still have to know about it – Mike Jan 30 '19 at 17:14
  • no, thats not true, you can access webapp with their own name from the app gateway. you have a freaking accepted answer that tells you that – 4c74356b41 Jan 30 '19 at 17:15
  • The accepted answer says that to accomplish the routing that describe in my question, I would have to deploy all of my apis and websites to the same app service and use virtual directories - "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." – Mike Jan 30 '19 at 17:27