1

I have ran into an issue where I am trying to deploy my api to a folder inside of app service on azure.

When I deployed directly to root directory it was working fine but the requirement is to have it in a api folder.
What I have done so far: on Azure portal inside of the configuratation->PathMappings i have added:

virtual path = /api

physical path = site\wwwroot\api

I downloaded the publishing profile directly from the portal. Imported it and changed the site url and destination url to have /api appended. I have been following this tutorial.

The deployment is executing fine from VS. I verified all files are there via FTP. When I try to navigate to the url I get a 404 error. The root directory shows the hostingstart.htm page.

From what I gathered it is to do with the web.config not being in the root directory and the service basically does not know how to handle this request.

So finally, my question is:

How should the web.config look like for a set up where the root director will serve flat html/css/js files and the api will sit inside of /api folder ?

kPieczonka
  • 394
  • 1
  • 14
  • Why would you try to run a web application from a folder inside a web application? I would question that requirement, I have a feeling someone misunderstands how app service plans work. – Crowcoder Jun 26 '20 at 12:25
  • @Crowcoder - so there is a front end application that uses the service that would sit inside of the root folder. – kPieczonka Jun 26 '20 at 12:29
  • I get that, but why not save the complication and deploy as it's own separate app service? – Crowcoder Jun 26 '20 at 12:30
  • So you suggest deploying the backend to root. then create another app service to run the front end (react native build with expo). As far as I understand CORS would become an issue then ? – kPieczonka Jun 26 '20 at 12:32
  • Its just my opinion. Maybe your way is perfectly valid, but you wouldn't be having this problem. Yes CORS would be an issue but not much of one. You can enable CORS in the app service in the azure portal easily. – Crowcoder Jun 26 '20 at 12:36
  • Is my answer useful to you ? If you need further help, pls let me know. – Jason Pan Jun 30 '20 at 01:52

1 Answers1

0

There is a Virtual applications and directories setting in the web app, which fully meets your needs.But the directory structure is different.

enter image description here

You can see my answer in another post, which has a specific introduction and points of attention.

My answer describes adding a sub application, you can also add access to static resource files.

In solving your problem, the services you need to use are Front Door, and you need to pay attention to the need to modify the .csproj file.

Jason Pan
  • 15,263
  • 1
  • 14
  • 29