Reputation: 1668
Let's say the main web app is: https:\mywebapp.com
Let's say I have separate Web API project and it has multiple services (api\service1, api\service2, )
For this I created 2 projects
How should I set up my project and publish profile in Azure so that I have the following
How do I achieve pt 2 and pt3 and have my web API project as a sub-app in my main web application? and share the same URL\api ?
Upvotes: 0
Views: 1529
Reputation: 20127
You could create virtual directory on same azure web app.
When you first create Core MVC Project in azure webapp, go to Configuration > Path mappings and config the Virtual directory site/api
.
When we publish the Core api to the Azure, we need to include the virtual directory path in the Site Name and Destination URL sections on the Connection tab.
Because Core 3.1 web api consists of one or more controller classes that derive from ControllerBase
. The web API project template provides a starter controller:
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
So, we can visit it just with controllerName. And as it is sub directory, so the Url path is api\controllerName
. Here is output:
Upvotes: 2