最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure - SOLVED - Setting up App Service with Application Gateway - Stack Overflow

programmeradmin0浏览0评论

I currently have the following environment: two App Services for Container, which are two Web APIs deployed with the default domain (azurewebsites) and public access that currently work well, example:

  • Swagger documentation endpoint: ...azurewebsites/swagger/index.html
  • Business logic endpoints like: ...azurewebsites/api/users/select)

Now I need to access them using Application Gateway with a result like the following:

  • https://< public-ip-app-gateway >/api1/swagger/index.html
  • https://< public-ip-app-gateway >/api2/swagger/index.html

that is, according to a path the App Gateway redirects me to the corresponding Web API and I can use the endpoints, this with the goal in the end that the Web APIs do not remain public

I followed the documentation to configure App Service with App Gateway and App Gateway with path-based routing rules but when I finish the steps and access the URLs I get a 404 Not Found

I would appreciate any additional information that I should take into account or that I am missing to carry out this configuration.

Update:

  • Log stream App Service:

    2025-02-19T13:22:20 Welcome, you are now connected to log- streaming service.Starting Log Tail -n 10 of existing logs ----/appsvctmp/volatile/logs/runtime/container.log 2025-02-19T13:21:18.2859098Z info: Microsoft.Hosting.Lifetime[14] 2025-02-19T13:21:18.2859870Z Now listening on: http://[::]:443 2025-02-19T13:21:18.2865131Z info: Microsoft.Hosting.Lifetime[0] 2025-02-19T13:21:18.2865338Z Application started. Press Ctrl+C to shut down. 2025-02-19T13:21:18.3039270Z info: Microsoft.Hosting.Lifetime[0] 2025-02-19T13:21:18.3039765Z Hosting environment: Production 2025-02-19T13:21:18.3039796Z info: Microsoft.Hosting.Lifetime[0] 2025-02-19T13:21:18.3039888Z Content root path: /app 2025-02-19T13:21:22.9290723Z warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] 2025-02-19T13:21:22.9293296Z Failed to determine the https port for redirect.Ending Log Tail of existing logs ---Starting Live Log Stream --- 2025-02-19T13:23:20 No new trace in the past 1 min(s).

Update 2:

  • Solution: The web api base path must match the path-based rule.

I currently have the following environment: two App Services for Container, which are two Web APIs deployed with the default domain (azurewebsites) and public access that currently work well, example:

  • Swagger documentation endpoint: ...azurewebsites/swagger/index.html
  • Business logic endpoints like: ...azurewebsites/api/users/select)

Now I need to access them using Application Gateway with a result like the following:

  • https://< public-ip-app-gateway >/api1/swagger/index.html
  • https://< public-ip-app-gateway >/api2/swagger/index.html

that is, according to a path the App Gateway redirects me to the corresponding Web API and I can use the endpoints, this with the goal in the end that the Web APIs do not remain public

I followed the documentation to configure App Service with App Gateway and App Gateway with path-based routing rules but when I finish the steps and access the URLs I get a 404 Not Found

I would appreciate any additional information that I should take into account or that I am missing to carry out this configuration.

Update:

  • Log stream App Service:

    2025-02-19T13:22:20 Welcome, you are now connected to log- streaming service.Starting Log Tail -n 10 of existing logs ----/appsvctmp/volatile/logs/runtime/container.log 2025-02-19T13:21:18.2859098Z info: Microsoft.Hosting.Lifetime[14] 2025-02-19T13:21:18.2859870Z Now listening on: http://[::]:443 2025-02-19T13:21:18.2865131Z info: Microsoft.Hosting.Lifetime[0] 2025-02-19T13:21:18.2865338Z Application started. Press Ctrl+C to shut down. 2025-02-19T13:21:18.3039270Z info: Microsoft.Hosting.Lifetime[0] 2025-02-19T13:21:18.3039765Z Hosting environment: Production 2025-02-19T13:21:18.3039796Z info: Microsoft.Hosting.Lifetime[0] 2025-02-19T13:21:18.3039888Z Content root path: /app 2025-02-19T13:21:22.9290723Z warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] 2025-02-19T13:21:22.9293296Z Failed to determine the https port for redirect.Ending Log Tail of existing logs ---Starting Live Log Stream --- 2025-02-19T13:23:20 No new trace in the past 1 min(s).

Update 2:

  • Solution: The web api base path must match the path-based rule.
Share Improve this question edited Mar 11 at 2:07 Daniel Cuellar asked Feb 19 at 0:52 Daniel CuellarDaniel Cuellar 33 bronze badges 2
  • Daniel Cuellar what does your azure app service log stream show? – Sirra Sneha Commented Feb 19 at 9:23
  • @SirraSneha the log stream of app service only show de logs of server start-up, I added in question – Daniel Cuellar Commented Feb 19 at 13:29
Add a comment  | 

1 Answer 1

Reset to default 0

when I finish the steps and access the URLs I get a 404 Not Found

Make sure both App Services are correctly added to the Backend Pool in Application Gateway like below.

As you have two App service, use path-based routing rules as shown below.

Rules-> Add multiple targets to create path-based rule -> Configure the Details ->Save.

Please refer this MS Documentation for better understanding about path-based routing.

  • As Azure Web Apps uses HTTPS, ensure Application Gateway Backend Settings also use HTTPS.

To know whether backend services are working fine or not, set up a Custom health probe in azure Application Gateway.

  • If the configured health probe receives a 200 OK response, Application Gateway routes traffic to that backend.

发布评论

评论列表(0)

  1. 暂无评论